package test;
import javax.swing.*;
import java.awt.Event;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class SwingTest implements ActionListener{
JFrame f;
JPanel p;
JLabel l1;
JLabel l2;
JTextField t;
JPasswordField jp;
JButton b;
public SwingTest(){
f = new JFrame();
p = new JPanel();
l1 = new JLabel("账号");
l2 = new JLabel("密码");
t = new JTextField(10);
b = new JButton("登录");
b.addActionListener(this);
jp = new JPasswordField(10);
p.add(l1);
p.add(t);
p.add(l2);
p.add(jp);
p.add(b);
f.add(p);
f.setVisible(true);
f.setSize(400,300);
}
public static void main(String[] args) {
new SwingTest();
}
@Override
public void actionPerformed(ActionEvent e) {
JFrame f2 = new JFrame();
JPanel p2 = new JPanel();
JButton b2 = new JButton("注册");
JLabel l3 = new JLabel("该账号未注册!");
p2.add(l3);
p2.add(b2);
f2.add(p2);
f2.setVisible(true);
f2.setSize(400,300);
}
}