package testButton;
import java.awt.*;
import java.awt.event.*;
public class testButton {
public static void main(String[] args){
Frame a = new Frame();
Button bn =new Button("hello");
a.add(bn);
A aa = new A();
bn.addActionListener(aa);
a.pack();
B bb = new B();
a.addWindowListener(bb);
a.setVisible(true);
}
}
class A implements ActionListener
{
public void actionPerformed(ActionEvent e){
System.out.printf("我很爽!\n");
//System.exit(0);
}
}
class B extends WindowAdapter{
public void WindowClosing (WindowEvent e){
System.exit(-1);
}
}
转载请注明原文地址: https://ju.6miu.com/read-36816.html