void (final Window window) { if (LOG.isDebugEnabled()) { LOG.debug("enter: dispatchClosed(" + window + ")"); } synchronized (myLock) { WindowInfo info = window == null ? null : windowToInfo.get(window); if (info != null) { final FocusWatcher focusWatcher = info.myFocusWatcherRef.get(); if (focusWatcher != null) { focusWatcher.deinstall(window); } windowToInfo.remove(window); } } // Now, we have to recalculate focused window if currently focused // window is being closed. if (myFocusedWindow == window) { if (LOG.isDebugEnabled()) { LOG.debug("currently active window should be closed"); } myFocusedWindow = myFocusedWindow.getOwner(); if (LOG.isDebugEnabled()) { LOG.debug("new active window is " + myFocusedWindow); } } for (Iterator<Window> i = myFocusedWindows.iterator(); i.hasNext(); ) { Window activeWindow = i.next(); if (activeWindow == window) { final Window newActiveWindow = activeWindow.getOwner(); i.remove(); if (newActiveWindow != null) { myFocusedWindows.add(newActiveWindow); } break; } } // Remove invalid infos for garbage collected windows for (Iterator<WindowInfo> i = windowToInfo.values().iterator(); i.hasNext(); ) { final WindowInfo info = i.next(); if (info.myFocusWatcherRef.get() == null) { if (LOG.isDebugEnabled()) { LOG.debug("remove collected info"); } i.remove(); } } }