Close a FrameTag(s): AWT
[JDK1.0.2]
public boolean handleEvent(Event evt) {
if (evt.id == Event.WINDOW_DESTROY) {
System.exit(0);
return true;
}
return super.handleEvent(evt);
}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);
}
}
);
}
}For a Dialog or a Window, a System.exit(0) may not be appropriate, call the dispose() method instead.
class SimplePopUp extends Dialog {
SimplePopUp() {
super(new Frame(), "simple popup");
this.addWindowListener
(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
e.getWindow().dispose();
}
}
);
}
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com