--- old/src/share/classes/java/awt/Container.java 2012-12-24 18:06:32.885284800 +0400 +++ new/src/share/classes/java/awt/Container.java 2012-12-24 18:06:32.744884600 +0400 @@ -3306,6 +3306,16 @@ } } + @Override + void clearLightweightDispatcherOnRemove(Component removedComponent) { + if (dispatcher != null) { + dispatcher.removeReferences(removedComponent); + } else { + //It is a Lightweight Container, should clear parent`s Dispatcher + super.clearLightweightDispatcherOnRemove(removedComponent); + } + } + final Container getTraversalRoot() { if (isFocusCycleRoot()) { return findTraversalRoot(); @@ -4389,6 +4399,7 @@ //System.out.println("Disposing lw dispatcher"); stopListeningForOtherDrags(); mouseEventTarget = null; + targetLastEntered = null; } /** @@ -4480,6 +4491,7 @@ // MOUSE_CLICKED. if (!isMouseGrab(e) && id != MouseEvent.MOUSE_CLICKED) { mouseEventTarget = (mouseOver != nativeContainer) ? mouseOver: null; + isCleaned = false; } if (mouseEventTarget != null) { @@ -4523,10 +4535,14 @@ retargetMouseEvent(mouseOver, id, e); break; } - //Consuming of wheel events is implemented in "retargetMouseEvent". - if (id != MouseEvent.MOUSE_WHEEL) { - e.consume(); - } + //Consuming of wheel events is implemented in "retargetMouseEvent". + if (id != MouseEvent.MOUSE_WHEEL) { + e.consume(); + } + } else if (isCleaned && id != MouseEvent.MOUSE_WHEEL) { + //After mouseEventTarget was removed and cleaned should consume all events + //until new mouseEventTarget is found + e.consume(); } return e.isConsumed(); } @@ -4870,6 +4886,11 @@ private transient Component targetLastEntered; /** + * Indicates whether {@code mouseEventTarget} was removed and nulled + */ + private transient boolean isCleaned; + + /** * Is the mouse over the native container */ private transient boolean isMouseInNativeContainer = false; @@ -4903,4 +4924,14 @@ AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK; + + void removeReferences(Component removedComponent) { + if (mouseEventTarget == removedComponent) { + isCleaned = true; + mouseEventTarget = null; + } + if (targetLastEntered == removedComponent) { + targetLastEntered = null; + } + } }