20110329

多種Close a Frame

public aFrame extends Frame implements WindowListener {
public aFrame(){
addWindowListener( this );
}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowClosing(WindowEvent e){ System.exit(0); }
public void windowClosed(WindowEvent e){}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
}
======================
public class aFrame extends Frame {
public aFrame(){
addWindowListener( new Terminate() );
}
}

class Terminate extends WindowAdapter{
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
======================
public class aFrame extends Frame {
public aFrame() {
addWindowListener
(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
);
}
}

沒有留言: