src/share/classes/java/awt/Container.java
Print this page
*** 3304,3313 ****
--- 3304,3323 ----
if (cont == this || isParentOf(cont)) {
kfm.setGlobalCurrentFocusCycleRootPriv(null);
}
}
+ @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();
}
*** 4409,4418 ****
--- 4419,4429 ----
*/
void dispose() {
//System.out.println("Disposing lw dispatcher");
stopListeningForOtherDrags();
mouseEventTarget = null;
+ targetLastEntered = null;
}
/**
* Enables events to subcomponents.
*/
*** 4500,4509 ****
--- 4511,4521 ----
// 4508327 : MOUSE_CLICKED should only go to the recipient of
// the accompanying MOUSE_PRESSED, so don't reset mouseEventTarget on a
// MOUSE_CLICKED.
if (!isMouseGrab(e) && id != MouseEvent.MOUSE_CLICKED) {
mouseEventTarget = (mouseOver != nativeContainer) ? mouseOver: null;
+ isCleaned = false;
}
if (mouseEventTarget != null) {
switch (id) {
case MouseEvent.MOUSE_ENTERED:
*** 4547,4556 ****
--- 4559,4572 ----
}
//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();
}
private boolean processDropTargetEvent(SunDropTargetEvent e) {
*** 4890,4899 ****
--- 4906,4920 ----
* The last component entered
*/
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;
/**
*** 4923,4928 ****
--- 4944,4959 ----
private static final long MOUSE_MASK =
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;
+ }
+ }
}