package com.jcomeau; import java.awt.*; import java.awt.event.*; // from _Java Examples in a Nutshell_, first edition, David Flanagan, p. 123 public class CloseableFrame extends Frame implements WindowListener { public static final long serialVersionUID = 0; public CloseableFrame() {this.addWindowListener(this);} public boolean disposed = false; public CloseableFrame(String title) { super(title); this.addWindowListener(this); } public void windowClosing(WindowEvent e) { this.disposed = true; // for testing Common.debug("window closed"); 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) {} }