1 package su;
2
3 import java.awt.Color;
4 import java.awt.event.ActionEvent;
5 import java.awt.event.ActionListener;
6
7 import javax.swing.*;
8 class a{
9
10 }
11 public class zeng implements ActionListener {
12 JPanel p; //面板
13 JFrame f; //窗口
14 JLabel g; //标签
15 JLabel a;
16 JTextField b; //文本行
17 JTextField c;
18 JButton d; //按钮
19 JButton z;
20
21 public void qqq() {
22 JPanel p = new JPanel();
23 JFrame f = new JFrame("注册窗口");
24 JButton a = new JButton("登录成功");
25 f.add(p);
26 p.add(a);
27 f.setSize(500,500);
28 f.setVisible(true);
29 }
30
31 public void liang() {
32 JPanel p = new JPanel();
33 JFrame f = new JFrame("注册窗口");
34 JLabel l1 = new JLabel("用户名");
35 JTextField b = new JTextField(10);
36 JLabel l2 = new JLabel("密码");
37 JTextField c = new JTextField(10);
38 JLabel l3 = new JLabel("确认密码");
39 JTextField d = new JTextField(10);
40 JButton a = new JButton("注册");
41 f.add(p);
42 p.add(l1);
43 p.add(b);
44 p.add(l2);
45 p.add(c);
46 p.add(l3);
47 p.add(d);
48 p.add(a);
49 f.setSize(500,500);
50 f.setVisible(true);
51
52 }
53 public void zen(){
54 p = new JPanel();
55 f = new JFrame("登录窗口");
56 g = new JLabel("账号:");
57 b = new JTextField(10);
58 a = new JLabel("密码:");
59 c = new JTextField(10);
60 d = new JButton("登录");
61 d.addActionListener(new ActionListener() {
62
63 @Override
64 public void actionPerformed(ActionEvent e) {
65 // TODO 自动生成的方法存根
66 f.setVisible(false);
67 zeng a = new zeng();
68 a.qqq();
69 }
70
71 });
72 z = new JButton("注册");
73 z.addActionListener(this);
74
75 f.add(p);
76 p.add(g);
77 p.add(b);
78 p.add(a);
79 p.add(c);
80 p.add(d);
81 p.add(z);
82 f.setSize(500,500);
83 f.setVisible(true);
84 }
85
86
87 public static void main(String[] args) {
88 zeng b = new zeng();
89 b.zen();
90 }
91
92 @Override
93 public void actionPerformed(ActionEvent e) {
94 // TODO 自动生成的方法存根
95 f.setVisible(false);
96 zeng a = new zeng();
97 a.liang();
98 }
99
100
101 }
![](https://img2018.cnblogs.com/blog/1639443/201905/1639443-20190516221332099-781586708.png)
![](https://img2018.cnblogs.com/blog/1639443/201905/1639443-20190516221344854-738604315.png)
![](https://img2018.cnblogs.com/blog/1639443/201905/1639443-20190516221514604-203136332.png)