actionPerformed

来源:互联网 发布:淘宝店铺手机端网址 编辑:程序博客网 时间:2024/06/05 08:41

import java.awt.*;
import java.awt.event.*;

class xt
{
static Button bb;
static Button cc;
public static void main(String in[])
{
Frame f=new Frame();
Frame g=new Frame();
f.setVisible(true);
g.setVisible(true);
f.setSize(500,500);
g.setSize(500,500);
f.setLayout(new FlowLayout());
g.setLayout(new FlowLayout());

bb=new Button("close123");
cc=new Button("close321");
f.add(bb);
g.add(cc);


bb.addActionListener                                            //不同点
(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource()== xt.bb)
System.exit(0);
}
}
);
/* cc.addActionListener                                            //不同点
(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource()== xt.cc)
System.exit(0);
}
}
*);*/
}
}

原创粉丝点击