java中窗体的转化

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class AA implements ActionListener{
    JFrame f;
    JPanel p;
    JButton b;
    JLabel l;
    JTextField t1;
    JTextField t2;
    public AA(){
        f = new JFrame();
        p = new JPanel();
        l = new JLabel();
        t1 = new JTextField(10);
        t2 = new JTextField(10);
        b = new JButton("账号:");
        p.add(b);
        p.add(t1);
        b = new JButton("密码:");
        p.add(b);
        p.add(t2);
        b = new JButton("登录");
        f.add(p);
        p.add(b);
        f.setSize(450,400);
        b.addActionListener(this);
        f.setVisible(true);
        
    }

    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        new AA();
    }

    @Override
    public void actionPerformed(ActionEvent arg0) {
        // TODO 自动生成的方法存根
        f.setVisible(false);
        JFrame f1;
        JPanel p1;
        JButton b1;
        f1 = new JFrame();
        p1 = new JPanel();
        b1 = new JButton("登录成功");
        f1.add(p1);
        p1.add(b1);
        f1.setSize(400, 400);
        p1.setBackground(Color.pink);
        f1.setVisible(true);
        
        
    }

}

猜你喜欢

转载自www.cnblogs.com/lvzhiqi/p/10872796.html