import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class SignIn extends JFrame implements Serializable{
private JLabel ab1,ab2,ab3;
private JTextField t1;
private JPasswordField pass;
private JButton bt1,bt2,bt3;
private JPanel jp1,jp2,jp3;
private static final long serialVersionUID = 16L;
SignIn(){
this.setTitle("界面测试");
this.setLayout(new GridLayout(4,1));
this.setResizable(false);
this.setBounds(300,300,300,300);
this.setDefaultCloseOperation(3);
init();
this.setVisible(true);
}
private void init() {
ab1=new JLabel("百度知道XX系统",JLabel.CENTER);
ab2=new JLabel("昵称:");
ab3=new JLabel("密码:");
t1=new JTextField(15);
pass=new JPasswordField(15);
bt1=new JButton("登陆");
bt2=new JButton("退出");
bt3=new JButton("注册");
jp1=new JPanel();
jp2=new JPanel();
jp3=new JPanel();
jp1.add(ab2);
jp1.add(t1);
jp2.add(ab3);
jp2.add(pass);
jp3.add(bt1);
jp3.add(bt2);
jp3.add(bt3);
event();
this.add(ab1);
this.add(jp1);
this.add(jp2);
this.add(jp3);
}
private void event() {
bt2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(1);
}
});
}
public static void main(String[] args) {
new SignIn();
}
}
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/e4dde71190ef76c609d91eb39016fdfaaf51671b?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)