public void showGotoDialog(final KeyEventBlocker blocker) { Dialog dialog = createGotoDialog(); if (dialog == null) { // already visible // TODO:beep() return; } dialog.setVisible(true); gotoPanel.popupNotify(blocker); WindowAdapter winAdapt = new WindowAdapter() { public @Override void windowClosing(WindowEvent evt) { disposeGotoDialog(); } public @Override void windowClosed(WindowEvent evt) { SwingUtilities.invokeLater( new Runnable() { public void run() { if (blocker != null) { blocker.stopBlocking(false); } // Utilities.returnFocus(); } }); } }; dialog.addWindowListener(winAdapt); }