Frame
puts up a window that responds to efforts to close it by calling setVisible(false)
and dispose()
.
import java.awt.*;
import java.awt.event.*;
public class ClosableFrame extends Frame implements WindowListener {
public ClosableFrame() {
this.addWindowListener(this);
}
public ClosableFrame(String s) {
super(s);
this.addWindowListener(this);
}
public void windowClosing(WindowEvent e) {
this.setVisible(false);
this.dispose();
}
public void windowOpened(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
}