package zouYe2;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class A6 {
public static void main(String[] args){
String user = "admin";
String password = "123456";
JFrame jFrame = new JFrame();
JLabel jLabel2,jLabel3;
ImageIcon imageIcon = new ImageIcon("src//上.jpg");
JLabel jLabel = new JLabel(imageIcon);
jLabel.setBounds(0,0,620,295);
jFrame.add(jLabel);
ImageIcon imageIcon1 = new ImageIcon("src//左.jpg");
JLabel jLabel1 = new JLabel(imageIcon1);
jLabel1.setBounds(0,295,241,241);
jFrame.add(jLabel1);
JTextField jTextField = new JTextField("请输入飞船号");
jTextField.setBounds(300,320,200,40);
jTextField.setFont(new Font( "宋体", Font.BOLD,30));
jFrame.add(jTextField);
jLabel2 = new JLabel("注册飞船号");
jLabel2.setBounds(510,320,80,30);
jFrame.add(jLabel2);
jLabel3 = new JLabel("忘记密码");
jLabel3.setBounds(510,385,80,30);
jFrame.add(jLabel3);
jTextField.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
if(jTextField.getText().equals("请输入飞船号")) {
jTextField.setText("");
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
if(jTextField.getText().equals("")) {
jTextField.setText("请输入飞船号");
}
}
});
JPasswordField jPasswordField = new JPasswordField();
jPasswordField.setBounds(300, 380, 200, 40);
jFrame.add(jPasswordField);
JButton jButton = new JButton("登录");
jButton.setBounds(350, 430, 100, 30);
jFrame.add(jButton);
jButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(jTextField.getText().equals(user)&&jPasswordField.getText().equals(password)){
jFrame.dispose();
JFrame jFrame1 = new JFrame("星游记");
FlowLayout flowLayout = new FlowLayout();
jFrame1.setLayout(flowLayout);
Dimension dimension = new Dimension(300,41);
JButton jButton1,jButton2,jButton3,jButton4,jButton5,jButton6,jButton7,jButton8,jButton9;
jButton1 = new JButton("麦当");
jButton1.setPreferredSize(dimension);
jButton1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFrame jFrame2 = new JFrame("麦当");
jTextField.setText("真正相信奇迹的家伙\n" +
"本身和奇迹一样了不起啊\n" +
"所以,不能让你停在这里");
jTextField.setFont(new Font("宋体", Font.BOLD,13));
jFrame2.add(jTextField);
jFrame2.setResizable(false);
jFrame2.setVisible(true);
jFrame2.setLocationRelativeTo(null);
jFrame2.setSize(1000, 400);
}
});
jButton2 = new JButton("麦林");
jButton2.setPreferredSize(dimension);
jButton2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFrame jFrame2 = new JFrame("麦林");
jTextField.setText("所有人都会有害怕的东西,\n" +
"但是感到恐惧就躲起来,世界就会变得越来越小\n" +
"第一到闪电,第一束火苗,让人类进步的所有事情都是有恐惧开始的,把最恐怖的地方变成最美丽的景色,这才是男人的梦想。");
jTextField.setFont(new Font("宋体", Font.BOLD,13));
jFrame2.add(jTextField);
jFrame2.setResizable(false);
jFrame2.setVisible(true);
jFrame2.setLocationRelativeTo(null);
jFrame2.setBounds(400,400,1300,400);
}
});
jButton3 = new JButton("哈雷");
jButton3.setPreferredSize(dimension);
jButton3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFrame jFrame2 = new JFrame("哈雷");
jTextField.setText("無恨恒星,本來就很了不起,它是爲了一个騎在木馬上的男孩\n" +
"爲了實现他的豪言壯語,才被造出來的不管那个宣言有多不可能,\n" +
"我希望有一天能再聽到一次。");
jTextField.setFont(new Font("宋体", Font.BOLD,13));
jFrame2.add(jTextField);
jFrame2.setResizable(false);
jFrame2.setVisible(true);
jFrame2.setLocationRelativeTo(null);
jFrame2.setSize(1000, 400);
}
});
jButton4 = new JButton("约士亚");
jButton4.setPreferredSize(dimension);
jButton4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFrame jFrame2 = new JFrame("约士亚");
jTextField.setText("王冠会让戴上它的人高人一头\n" +
"是地位的象征,但王冠真正的意义是\n" +
"当灾难从天而降时,我会为你们抵挡一切,永远让你们只看到金色的希望。");
jTextField.setFont(new Font("宋体", Font.BOLD,13));
jFrame2.add(jTextField);
jFrame2.setResizable(false);
jFrame2.setVisible(true);
jFrame2.setLocationRelativeTo(null);
jFrame2.setSize(1000, 380);
}
});
jButton5 = new JButton("盖亚");
jButton5.setPreferredSize(dimension);
jButton5.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFrame jFrame2 = new JFrame("盖亚");
jTextField.setText("星空之所以美丽,就是因为在无限的宇宙中\n" +
"不管黑暗如何蔓延,都有星星的光芒,去把他照亮\n" +
"世界也是这样,有绝望的地方,就会有希望产生,拥有希望的人,和满天的星星一样,是永远不会孤独的"+
"找到和自己一样的星星,把通往自由的路照亮吧!");
jTextField.setFont(new Font("宋体", Font.BOLD,13));
jFrame2.add(jTextField);
jFrame2.setResizable(false);
jFrame2.setVisible(true);
jFrame2.setLocationRelativeTo(null);
jFrame2.setBounds(200,400,1700,400);
}
});
jButton6 = new JButton("米龙");
jButton6.setPreferredSize(dimension);
jButton6.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFrame jFrame2 = new JFrame("米龙");
jTextField.setText("世界上最美的是人的微笑啊\n" +
"把所有人都踩在脚下,才能登上的顶峰,还能看到什么风景呢");
jTextField.setFont(new Font("宋体", Font.BOLD,13));
jFrame2.add(jTextField);
jFrame2.setResizable(false);
jFrame2.setVisible(true);
jFrame2.setLocationRelativeTo(null);
jFrame2.setSize(1000, 400);
}
});
jButton7 = new JButton("米吉");
jButton7.setPreferredSize(dimension);
jButton7.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFrame jFrame2 = new JFrame("米吉");
jTextField.setText("大家一样想努力长大,它们又没做错什么事\n" +
"因为拔掉草才好看的花,小草自己却看不见\n" +
"做这么狠心事的人,又怎么有资格欣赏好看的花呢");
jTextField.setFont(new Font("宋体", Font.BOLD,13));
jFrame2.add(jTextField);
jFrame2.setResizable(false);
jFrame2.setVisible(true);
jFrame2.setLocationRelativeTo(null);
jFrame2.setSize(1000, 400);
}
});
jButton8 = new JButton("迪亚");
jButton8.setPreferredSize(dimension);
jButton8.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFrame jFrame2 = new JFrame("迪亚");
jTextField.setText("相信奇迹的人\n" +
"本身和奇迹一样了不起对吧\n" +
"所以,不能让你停在这里");
jTextField.setFont(new Font("宋体", Font.BOLD,13));
jFrame2.add(jTextField);
jFrame2.setResizable(false);
jFrame2.setVisible(true);
jFrame2.setLocationRelativeTo(null);
jFrame2.setSize(1000, 400);
}
});
jButton9 = new JButton("咕咚");
jButton9.setPreferredSize(dimension);
jButton9.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFrame jFrame2 = new JFrame("咕咚");
jTextField.setText("出发,国王号,目标,彩虹海");
jTextField.setFont(new Font("宋体", Font.BOLD,13));
jFrame2.add(jTextField);
jFrame2.setResizable(false);
jFrame2.setVisible(true);
jFrame2.setLocationRelativeTo(null);
jFrame2.setSize(1000, 400);
}
});
jFrame1.add(jButton1);
jFrame1.add(jButton2);
jFrame1.add(jButton3);
jFrame1.add(jButton4);
jFrame1.add(jButton5);
jFrame1.add(jButton6);
jFrame1.add(jButton7);
jFrame1.add(jButton8);
jFrame1.add(jButton9);
jFrame1.setVisible(true);
jFrame1.setResizable(false);
jFrame1.setSize(300, 800);
jFrame1.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}else {
JOptionPane.showMessageDialog(null, "用户名或密码错误,",
"请重新输入",JOptionPane.ERROR_MESSAGE);
}
}
});
jTextField.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
if(e.getKeyChar()=='\n') {
jButton.doClick();
}
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
}
});
jPasswordField.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
if(e.getKeyChar()=='\n') {
jButton.doClick();
}
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
}
});
jFrame.setSize(620, 560);
jFrame.setResizable(false);
jFrame.setLayout(null);
jFrame.setLocationRelativeTo(null);
jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
jFrame.setVisible(true);
}
}
//给我高高的飞起来
|