package guweiyi;
import java.awt.Color;
import javax.swing.*;
public class MyFrame {
JFrame f;
JPanel p;
JLabel l1;
JLabel l2;
JButton b;
JTextField t1;
JTextField t2;
public MyFrame(){
f=new JFrame("登陆窗口");
p=new JPanel();
l1=new JLabel("账号:");
l2=new JLabel("密码:");
t1=new JTextField(10);
t2=new JTextField(10);
b=new JButton("登陆");
f.add(p);
p.add(l1);
p.add(t1);
p.add(l2);
p.add(t2);
p.add(b);
f.setLocation(500,300);
f.setSize(400, 250);
f.setVisible(true);
p.setBackground(Color.pink);
}
public static void main(String[] args){
new MyFrame();
}
}
只会这种比较简单的,当程序要求增加的时候,就容易乱。![]()