public class shubiaoshijian{
public static void main(String[] args){
new Frame1();
}
}
class Frame1 extend Frame implements ActionListener{
Button btn;
Frame1(){
super("我的窗口");
btn=new Button("关闭");
setLayout(new FlowLayout());
add(btn);
setSize(300,300);
setVisible(true);
}
public void actionPerformed(ActionEvent e){
if(e.getActionCommand()=="关闭"){
dispose();
System.exit(0);
}
}
}
class CloseWin extend WindowAdapter{
public void windowClosing(WindowEvent e){
Frame frm=(Frame)(e.getSource());
frm.dispose();
System.exit(0);
}
}