事件处理程序

package wenyi;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class kevin implements ActionListener {
      JFrame f;
      JPanel p;
      JLabel l;
      JButton b;
      JTextField t;
      public kevin(){
       f=new JFrame();
       p=new JPanel();
       l=new JLabel("登录:");
       t=new JTextField(10);
       b=new JButton("确定:");
       f.add(p);
       p.add(l);
       p.add(t);
       p.add(b);
       f.setVisible(true);
       f.setSize(300,200);
       b.addActionListener(this);
      }
      public void ljy(){
       f=new JFrame();
       p=new JPanel();
       l=new JLabel("登录成功!");
       f.add(p);
       p.add(l);
       f.setVisible(true);
       f.setSize(300,200);
      }
      public static void main(String[] args){
       new kevin();
      }
      public void actionPerformed(ActionEvent arg0){
      
       p.setBackground(Color.black);
      new kevin();
      f.setLocation(320, 200);
            ljy();
      }
}

posted on 2019-05-10 11:33  傅凯文  阅读(128)  评论(0编辑  收藏  举报