窗口的切换

 1 package com.wsy.work2;
 2 
 3 import java.awt.GridLayout;
 4 import java.awt.event.ActionEvent;
 5 import java.awt.event.ActionListener;
 6 
 7 import javax.swing.JButton;
 8 import javax.swing.JFrame;
 9 import javax.swing.JLabel;
10 import javax.swing.JPanel;
11 import javax.swing.JTextArea;
12 
13 public class WindowsSwitch {
14     JFrame jf;
15     JButton jb1;
16     JButton jb2;
17     JPanel jp;
18     JLabel jl;
19     public WindowsSwitch() 
20     {
21         jf = new JFrame();
22         jb1 = new JButton("注册");
23         jb2 = new JButton("登录");
24         jp = new JPanel();
25         jl = new JLabel("欢迎使用本程序\n请选择您需要进行的操作");
26         jb1.addActionListener(new ActionListener() {
27             @Override
28             public void actionPerformed(ActionEvent e) {
29                 JFrame jf1 = new JFrame();
30                 JPanel jp1 = new JPanel();
31                 JLabel jl1 = new JLabel("请输入您的手机号和您的个人信息");
32                 JTextArea jta1 = new JTextArea(3,10);
33                 jf.setVisible(false);
34                 jta1.setLineWrap(true);
35                 jp1.add(jl1);
36                 jp1.add(jta1);
37                 jf1.add(jp1);
38                 jf1.setSize(600,200);
39                 jf1.setLocation(800, 400);
40                 jf1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
41                 jf1.setVisible(true);
42             }
43         });
44         jb2.addActionListener(new ActionListener() {
45             @Override
46             public void actionPerformed(ActionEvent e) {
47                 JFrame jf1 = new JFrame();
48                 JPanel jp1 = new JPanel();
49                 JLabel jl1 = new JLabel("登陆成功");
50                 jf.setVisible(false);
51                 jp1.add(jl1);
52                 jf1.add(jp1);
53                 jf1.setSize(200,100);
54                 jf1.setLocation(800, 400);
55                 jf1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
56                 jf1.setVisible(true);
57             }
58         });
59         jp.add(jl);
60         jp.add(jb1); 
61         jp.add(jb2);
62         jf.add(jp);
63         jf.setSize(300,100);
64         jf.setLocation(800, 400);
65         jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
66         jf.setVisible(true);
67     }
68     public static void main(String[] args) {
69         new WindowsSwitch();
70 
71     }
72 
73 
74 }

 

 

你可能感兴趣的:(窗口的切换)