List of usage examples for java.awt Frame removeWindowListener
public synchronized void removeWindowListener(WindowListener l)
From source file:ModalFrameUtil.java
public static void showAsModal(final Frame frame, final Frame owner) { frame.addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) { owner.setEnabled(false);/*from w w w . ja v a2s . co m*/ } public void windowClosing(WindowEvent e) { owner.setEnabled(true); frame.removeWindowListener(this); } public void windowClosed(WindowEvent e) { owner.setEnabled(true); frame.removeWindowListener(this); } }); owner.addWindowListener(new WindowAdapter() { public void windowActivated(WindowEvent e) { if (frame.isShowing()) { frame.setExtendedState(JFrame.NORMAL); frame.toFront(); } else { owner.removeWindowListener(this); } } }); frame.setVisible(true); try { new EventPump(frame).start(); } catch (Throwable throwable) { throw new RuntimeException(throwable); } }