事件处理

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(); 
} 
}

 

posted @ 2019-07-03 14:58  畅大哥  阅读(79)  评论(0编辑  收藏  举报