--- old/src/share/classes/java/awt/Window.java 2012-02-22 19:53:42.804175100 +0400 +++ new/src/share/classes/java/awt/Window.java 2012-02-22 19:53:41.971127500 +0400 @@ -226,7 +226,8 @@ static boolean systemSyncLWRequests = false; boolean syncLWRequests = false; transient boolean beforeFirstShow = true; - + private transient boolean disposing = false; + static final int OPENED = 0x01; /** @@ -1162,36 +1163,41 @@ void doDispose() { class DisposeAction implements Runnable { public void run() { - // Check if this window is the fullscreen window for the - // device. Exit the fullscreen mode prior to disposing - // of the window if that's the case. - GraphicsDevice gd = getGraphicsConfiguration().getDevice(); - if (gd.getFullScreenWindow() == Window.this) { - gd.setFullScreenWindow(null); - } - - Object[] ownedWindowArray; - synchronized(ownedWindowList) { - ownedWindowArray = new Object[ownedWindowList.size()]; - ownedWindowList.copyInto(ownedWindowArray); - } - for (int i = 0; i < ownedWindowArray.length; i++) { - Window child = (Window) (((WeakReference) - (ownedWindowArray[i])).get()); - if (child != null) { - child.disposeImpl(); + disposing = true; + try { + // Check if this window is the fullscreen window for the + // device. Exit the fullscreen mode prior to disposing + // of the window if that's the case. + GraphicsDevice gd = getGraphicsConfiguration().getDevice(); + if (gd.getFullScreenWindow() == Window.this) { + gd.setFullScreenWindow(null); } - } - hide(); - beforeFirstShow = true; - removeNotify(); - synchronized (inputContextLock) { - if (inputContext != null) { - inputContext.dispose(); - inputContext = null; + + Object[] ownedWindowArray; + synchronized(ownedWindowList) { + ownedWindowArray = new Object[ownedWindowList.size()]; + ownedWindowList.copyInto(ownedWindowArray); + } + for (int i = 0; i < ownedWindowArray.length; i++) { + Window child = (Window) (((WeakReference) + (ownedWindowArray[i])).get()); + if (child != null) { + child.disposeImpl(); + } + } + hide(); + beforeFirstShow = true; + removeNotify(); + synchronized (inputContextLock) { + if (inputContext != null) { + inputContext.dispose(); + inputContext = null; + } } + clearCurrentFocusCycleRootOnHide(); + } finally { + disposing = false; } - clearCurrentFocusCycleRootOnHide(); } } DisposeAction action = new DisposeAction(); @@ -2734,6 +2740,10 @@ return visible; } + boolean isDisposing() { + return disposing; + } + /** * @deprecated As of J2SE 1.4, replaced by * {@link Component#applyComponentOrientation Component.applyComponentOrientation}.