@Override public void setVisible(boolean isVisible) { if (!wrappedDialog.isModal()) { if (isVisible) { // set old mode again wrappedDialog.addWindowFocusListener(this); } else { wrappedDialog.removeWindowFocusListener(this); app.setSelectionListenerMode(null); } } // clean up on exit: either remove our geo or keep it and make it // visible if (!isVisible) { if (keepNewGeo) { addNewGeoToConstruction(); } else { newGeo.remove(); } } super.setVisible(isVisible); }