import java.awt.*; public class CloseableDialog extends Dialog { Frame parent; public CloseableDialog(Frame parent, String title, boolean modal) { super(parent,title,modal); this.parent=parent; setBackground(Color.lightGray); } public Frame getParentFrame() { return parent; } public boolean handleEvent(Event e) { switch(e.id) { case Event.WINDOW_DESTROY: hide(); dispose(); return true; case Event.WINDOW_ICONIFY: hide(); return true; case Event.WINDOW_DEICONIFY: show(); return true; default: return super.handleEvent(e); } } }