58 import java.lang.reflect.InvocationTargetException; |
58 import java.lang.reflect.InvocationTargetException; |
59 import java.lang.reflect.Method; |
59 import java.lang.reflect.Method; |
60 import java.security.AccessController; |
60 import java.security.AccessController; |
61 import java.security.PrivilegedAction; |
61 import java.security.PrivilegedAction; |
62 import javax.accessibility.*; |
62 import javax.accessibility.*; |
63 import java.util.logging.*; |
|
64 import java.applet.Applet; |
63 import java.applet.Applet; |
65 |
64 |
66 import sun.security.action.GetPropertyAction; |
65 import sun.security.action.GetPropertyAction; |
67 import sun.awt.AppContext; |
66 import sun.awt.AppContext; |
68 import sun.awt.AWTAccessor; |
67 import sun.awt.AWTAccessor; |
82 import sun.awt.image.VSyncedBSManager; |
81 import sun.awt.image.VSyncedBSManager; |
83 import sun.java2d.pipe.hw.ExtendedBufferCapabilities; |
82 import sun.java2d.pipe.hw.ExtendedBufferCapabilities; |
84 import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*; |
83 import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*; |
85 import sun.awt.RequestFocusController; |
84 import sun.awt.RequestFocusController; |
86 import sun.java2d.SunGraphicsEnvironment; |
85 import sun.java2d.SunGraphicsEnvironment; |
|
86 import sun.util.logging.PlatformLogger; |
87 |
87 |
88 /** |
88 /** |
89 * A <em>component</em> is an object having a graphical representation |
89 * A <em>component</em> is an object having a graphical representation |
90 * that can be displayed on the screen and that can interact with the |
90 * that can be displayed on the screen and that can interact with the |
91 * user. Examples of components are the buttons, checkboxes, and scrollbars |
91 * user. Examples of components are the buttons, checkboxes, and scrollbars |
176 */ |
176 */ |
177 public abstract class Component implements ImageObserver, MenuContainer, |
177 public abstract class Component implements ImageObserver, MenuContainer, |
178 Serializable |
178 Serializable |
179 { |
179 { |
180 |
180 |
181 private static final Logger log = Logger.getLogger("java.awt.Component"); |
181 private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.Component"); |
182 private static final Logger eventLog = Logger.getLogger("java.awt.event.Component"); |
182 private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.Component"); |
183 private static final Logger focusLog = Logger.getLogger("java.awt.focus.Component"); |
183 private static final PlatformLogger focusLog = PlatformLogger.getLogger("java.awt.focus.Component"); |
184 private static final Logger mixingLog = Logger.getLogger("java.awt.mixing.Component"); |
184 private static final PlatformLogger mixingLog = PlatformLogger.getLogger("java.awt.mixing.Component"); |
185 |
185 |
186 /** |
186 /** |
187 * The peer of the component. The peer implements the component's |
187 * The peer of the component. The peer implements the component's |
188 * behavior. The peer is set when the <code>Component</code> is |
188 * behavior. The peer is set when the <code>Component</code> is |
189 * added to a container that also is a peer. |
189 * added to a container that also is a peer. |
4476 int id = e.getID(); |
4476 int id = e.getID(); |
4477 |
4477 |
4478 // Check that this component belongs to this app-context |
4478 // Check that this component belongs to this app-context |
4479 AppContext compContext = appContext; |
4479 AppContext compContext = appContext; |
4480 if (compContext != null && !compContext.equals(AppContext.getAppContext())) { |
4480 if (compContext != null && !compContext.equals(AppContext.getAppContext())) { |
4481 if (eventLog.isLoggable(Level.FINE)) { |
4481 if (eventLog.isLoggable(PlatformLogger.FINE)) { |
4482 eventLog.log(Level.FINE, "Event " + e + " is being dispatched on the wrong AppContext"); |
4482 eventLog.fine("Event " + e + " is being dispatched on the wrong AppContext"); |
4483 } |
4483 } |
4484 } |
4484 } |
4485 |
4485 |
4486 if (eventLog.isLoggable(Level.FINEST)) { |
4486 if (eventLog.isLoggable(PlatformLogger.FINEST)) { |
4487 eventLog.log(Level.FINEST, "{0}", e); |
4487 eventLog.finest("{0}", e); |
4488 } |
4488 } |
4489 |
4489 |
4490 /* |
4490 /* |
4491 * 0. Set timestamp and modifiers of current event. |
4491 * 0. Set timestamp and modifiers of current event. |
4492 */ |
4492 */ |
4517 dispatchEvent(e)) |
4517 dispatchEvent(e)) |
4518 { |
4518 { |
4519 return; |
4519 return; |
4520 } |
4520 } |
4521 } |
4521 } |
4522 if ((e instanceof FocusEvent) && focusLog.isLoggable(Level.FINEST)) { |
4522 if ((e instanceof FocusEvent) && focusLog.isLoggable(PlatformLogger.FINEST)) { |
4523 focusLog.log(Level.FINEST, "" + e); |
4523 focusLog.finest("" + e); |
4524 } |
4524 } |
4525 // MouseWheel may need to be retargeted here so that |
4525 // MouseWheel may need to be retargeted here so that |
4526 // AWTEventListener sees the event go to the correct |
4526 // AWTEventListener sees the event go to the correct |
4527 // Component. If the MouseWheelEvent needs to go to an ancestor, |
4527 // Component. If the MouseWheelEvent needs to go to an ancestor, |
4528 // the event is dispatched to the ancestor, and dispatching here |
4528 // the event is dispatched to the ancestor, and dispatching here |
4610 case KeyEvent.KEY_RELEASED: |
4610 case KeyEvent.KEY_RELEASED: |
4611 Container p = (Container)((this instanceof Container) ? this : parent); |
4611 Container p = (Container)((this instanceof Container) ? this : parent); |
4612 if (p != null) { |
4612 if (p != null) { |
4613 p.preProcessKeyEvent((KeyEvent)e); |
4613 p.preProcessKeyEvent((KeyEvent)e); |
4614 if (e.isConsumed()) { |
4614 if (e.isConsumed()) { |
4615 if (focusLog.isLoggable(Level.FINEST)) { |
4615 if (focusLog.isLoggable(PlatformLogger.FINEST)) { |
4616 focusLog.log(Level.FINEST, "Pre-process consumed event"); |
4616 focusLog.finest("Pre-process consumed event"); |
4617 } |
4617 } |
4618 return; |
4618 return; |
4619 } |
4619 } |
4620 } |
4620 } |
4621 break; |
4621 break; |
4743 newY = e.getY() + getY(); // the cursor's position relative to this |
4743 newY = e.getY() + getY(); // the cursor's position relative to this |
4744 // Component (e.getX()), and this Component's |
4744 // Component (e.getX()), and this Component's |
4745 // position relative to its parent. |
4745 // position relative to its parent. |
4746 MouseWheelEvent newMWE; |
4746 MouseWheelEvent newMWE; |
4747 |
4747 |
4748 if (eventLog.isLoggable(Level.FINEST)) { |
4748 if (eventLog.isLoggable(PlatformLogger.FINEST)) { |
4749 eventLog.log(Level.FINEST, "dispatchMouseWheelToAncestor"); |
4749 eventLog.finest("dispatchMouseWheelToAncestor"); |
4750 eventLog.log(Level.FINEST, "orig event src is of " + e.getSource().getClass()); |
4750 eventLog.finest("orig event src is of " + e.getSource().getClass()); |
4751 } |
4751 } |
4752 |
4752 |
4753 /* parent field for Window refers to the owning Window. |
4753 /* parent field for Window refers to the owning Window. |
4754 * MouseWheelEvents should NOT be propagated into owning Windows |
4754 * MouseWheelEvents should NOT be propagated into owning Windows |
4755 */ |
4755 */ |
4766 else { |
4766 else { |
4767 break; |
4767 break; |
4768 } |
4768 } |
4769 } |
4769 } |
4770 |
4770 |
4771 if (eventLog.isLoggable(Level.FINEST)) { |
4771 if (eventLog.isLoggable(PlatformLogger.FINEST)) { |
4772 eventLog.log(Level.FINEST, "new event src is " + anc.getClass()); |
4772 eventLog.finest("new event src is " + anc.getClass()); |
4773 } |
4773 } |
4774 |
4774 |
4775 if (anc != null && anc.eventEnabled(e)) { |
4775 if (anc != null && anc.eventEnabled(e)) { |
4776 // Change event to be from new source, with new x,y |
4776 // Change event to be from new source, with new x,y |
4777 // For now, just create a new event - yucky |
4777 // For now, just create a new event - yucky |
5262 } |
5262 } |
5263 |
5263 |
5264 // Should only be called while holding the tree lock |
5264 // Should only be called while holding the tree lock |
5265 int numListening(long mask) { |
5265 int numListening(long mask) { |
5266 // One mask or the other, but not neither or both. |
5266 // One mask or the other, but not neither or both. |
5267 if (eventLog.isLoggable(Level.FINE)) { |
5267 if (eventLog.isLoggable(PlatformLogger.FINE)) { |
5268 if ((mask != AWTEvent.HIERARCHY_EVENT_MASK) && |
5268 if ((mask != AWTEvent.HIERARCHY_EVENT_MASK) && |
5269 (mask != AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK)) |
5269 (mask != AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK)) |
5270 { |
5270 { |
5271 eventLog.log(Level.FINE, "Assertion failed"); |
5271 eventLog.fine("Assertion failed"); |
5272 } |
5272 } |
5273 } |
5273 } |
5274 if ((mask == AWTEvent.HIERARCHY_EVENT_MASK && |
5274 if ((mask == AWTEvent.HIERARCHY_EVENT_MASK && |
5275 (hierarchyListener != null || |
5275 (hierarchyListener != null || |
5276 (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0)) || |
5276 (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0)) || |
5303 return 1; |
5303 return 1; |
5304 } |
5304 } |
5305 break; |
5305 break; |
5306 case HierarchyEvent.ANCESTOR_MOVED: |
5306 case HierarchyEvent.ANCESTOR_MOVED: |
5307 case HierarchyEvent.ANCESTOR_RESIZED: |
5307 case HierarchyEvent.ANCESTOR_RESIZED: |
5308 if (eventLog.isLoggable(Level.FINE)) { |
5308 if (eventLog.isLoggable(PlatformLogger.FINE)) { |
5309 if (changeFlags != 0) { |
5309 if (changeFlags != 0) { |
5310 eventLog.log(Level.FINE, "Assertion (changeFlags == 0) failed"); |
5310 eventLog.fine("Assertion (changeFlags == 0) failed"); |
5311 } |
5311 } |
5312 } |
5312 } |
5313 if (hierarchyBoundsListener != null || |
5313 if (hierarchyBoundsListener != null || |
5314 (eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0 || |
5314 (eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0 || |
5315 enabledOnToolkit) { |
5315 enabledOnToolkit) { |
7381 final boolean requestFocusHelper(boolean temporary, |
7381 final boolean requestFocusHelper(boolean temporary, |
7382 boolean focusedWindowChangeAllowed, |
7382 boolean focusedWindowChangeAllowed, |
7383 CausedFocusEvent.Cause cause) |
7383 CausedFocusEvent.Cause cause) |
7384 { |
7384 { |
7385 if (!isRequestFocusAccepted(temporary, focusedWindowChangeAllowed, cause)) { |
7385 if (!isRequestFocusAccepted(temporary, focusedWindowChangeAllowed, cause)) { |
7386 if (focusLog.isLoggable(Level.FINEST)) { |
7386 if (focusLog.isLoggable(PlatformLogger.FINEST)) { |
7387 focusLog.log(Level.FINEST, "requestFocus is not accepted"); |
7387 focusLog.finest("requestFocus is not accepted"); |
7388 } |
7388 } |
7389 return false; |
7389 return false; |
7390 } |
7390 } |
7391 |
7391 |
7392 // Update most-recent map |
7392 // Update most-recent map |
7393 KeyboardFocusManager.setMostRecentFocusOwner(this); |
7393 KeyboardFocusManager.setMostRecentFocusOwner(this); |
7394 |
7394 |
7395 Component window = this; |
7395 Component window = this; |
7396 while ( (window != null) && !(window instanceof Window)) { |
7396 while ( (window != null) && !(window instanceof Window)) { |
7397 if (!window.isVisible()) { |
7397 if (!window.isVisible()) { |
7398 if (focusLog.isLoggable(Level.FINEST)) { |
7398 if (focusLog.isLoggable(PlatformLogger.FINEST)) { |
7399 focusLog.log(Level.FINEST, "component is recurively invisible"); |
7399 focusLog.finest("component is recurively invisible"); |
7400 } |
7400 } |
7401 return false; |
7401 return false; |
7402 } |
7402 } |
7403 window = window.parent; |
7403 window = window.parent; |
7404 } |
7404 } |
7405 |
7405 |
7406 ComponentPeer peer = this.peer; |
7406 ComponentPeer peer = this.peer; |
7407 Component heavyweight = (peer instanceof LightweightPeer) |
7407 Component heavyweight = (peer instanceof LightweightPeer) |
7408 ? getNativeContainer() : this; |
7408 ? getNativeContainer() : this; |
7409 if (heavyweight == null || !heavyweight.isVisible()) { |
7409 if (heavyweight == null || !heavyweight.isVisible()) { |
7410 if (focusLog.isLoggable(Level.FINEST)) { |
7410 if (focusLog.isLoggable(PlatformLogger.FINEST)) { |
7411 focusLog.log(Level.FINEST, "Component is not a part of visible hierarchy"); |
7411 focusLog.finest("Component is not a part of visible hierarchy"); |
7412 } |
7412 } |
7413 return false; |
7413 return false; |
7414 } |
7414 } |
7415 peer = heavyweight.peer; |
7415 peer = heavyweight.peer; |
7416 if (peer == null) { |
7416 if (peer == null) { |
7417 if (focusLog.isLoggable(Level.FINEST)) { |
7417 if (focusLog.isLoggable(PlatformLogger.FINEST)) { |
7418 focusLog.log(Level.FINEST, "Peer is null"); |
7418 focusLog.finest("Peer is null"); |
7419 } |
7419 } |
7420 return false; |
7420 return false; |
7421 } |
7421 } |
7422 |
7422 |
7423 // Focus this Component |
7423 // Focus this Component |
7425 boolean success = peer.requestFocus |
7425 boolean success = peer.requestFocus |
7426 (this, temporary, focusedWindowChangeAllowed, time, cause); |
7426 (this, temporary, focusedWindowChangeAllowed, time, cause); |
7427 if (!success) { |
7427 if (!success) { |
7428 KeyboardFocusManager.getCurrentKeyboardFocusManager |
7428 KeyboardFocusManager.getCurrentKeyboardFocusManager |
7429 (appContext).dequeueKeyEvents(time, this); |
7429 (appContext).dequeueKeyEvents(time, this); |
7430 if (focusLog.isLoggable(Level.FINEST)) { |
7430 if (focusLog.isLoggable(PlatformLogger.FINEST)) { |
7431 focusLog.log(Level.FINEST, "Peer request failed"); |
7431 focusLog.finest("Peer request failed"); |
7432 } |
7432 } |
7433 } else { |
7433 } else { |
7434 if (focusLog.isLoggable(Level.FINEST)) { |
7434 if (focusLog.isLoggable(PlatformLogger.FINEST)) { |
7435 focusLog.log(Level.FINEST, "Pass for " + this); |
7435 focusLog.finest("Pass for " + this); |
7436 } |
7436 } |
7437 } |
7437 } |
7438 return success; |
7438 return success; |
7439 } |
7439 } |
7440 |
7440 |
7441 private boolean isRequestFocusAccepted(boolean temporary, |
7441 private boolean isRequestFocusAccepted(boolean temporary, |
7442 boolean focusedWindowChangeAllowed, |
7442 boolean focusedWindowChangeAllowed, |
7443 CausedFocusEvent.Cause cause) |
7443 CausedFocusEvent.Cause cause) |
7444 { |
7444 { |
7445 if (!isFocusable() || !isVisible()) { |
7445 if (!isFocusable() || !isVisible()) { |
7446 if (focusLog.isLoggable(Level.FINEST)) { |
7446 if (focusLog.isLoggable(PlatformLogger.FINEST)) { |
7447 focusLog.log(Level.FINEST, "Not focusable or not visible"); |
7447 focusLog.finest("Not focusable or not visible"); |
7448 } |
7448 } |
7449 return false; |
7449 return false; |
7450 } |
7450 } |
7451 |
7451 |
7452 ComponentPeer peer = this.peer; |
7452 ComponentPeer peer = this.peer; |
7453 if (peer == null) { |
7453 if (peer == null) { |
7454 if (focusLog.isLoggable(Level.FINEST)) { |
7454 if (focusLog.isLoggable(PlatformLogger.FINEST)) { |
7455 focusLog.log(Level.FINEST, "peer is null"); |
7455 focusLog.finest("peer is null"); |
7456 } |
7456 } |
7457 return false; |
7457 return false; |
7458 } |
7458 } |
7459 |
7459 |
7460 Window window = getContainingWindow(); |
7460 Window window = getContainingWindow(); |
7461 if (window == null || !((Window)window).isFocusableWindow()) { |
7461 if (window == null || !((Window)window).isFocusableWindow()) { |
7462 if (focusLog.isLoggable(Level.FINEST)) { |
7462 if (focusLog.isLoggable(PlatformLogger.FINEST)) { |
7463 focusLog.log(Level.FINEST, "Component doesn't have toplevel"); |
7463 focusLog.finest("Component doesn't have toplevel"); |
7464 } |
7464 } |
7465 return false; |
7465 return false; |
7466 } |
7466 } |
7467 |
7467 |
7468 // We have passed all regular checks for focus request, |
7468 // We have passed all regular checks for focus request, |
7479 |
7479 |
7480 if (focusOwner == this || focusOwner == null) { |
7480 if (focusOwner == this || focusOwner == null) { |
7481 // Controller is supposed to verify focus transfers and for this it |
7481 // Controller is supposed to verify focus transfers and for this it |
7482 // should know both from and to components. And it shouldn't verify |
7482 // should know both from and to components. And it shouldn't verify |
7483 // transfers from when these components are equal. |
7483 // transfers from when these components are equal. |
7484 if (focusLog.isLoggable(Level.FINEST)) { |
7484 if (focusLog.isLoggable(PlatformLogger.FINEST)) { |
7485 focusLog.log(Level.FINEST, "focus owner is null or this"); |
7485 focusLog.finest("focus owner is null or this"); |
7486 } |
7486 } |
7487 return true; |
7487 return true; |
7488 } |
7488 } |
7489 |
7489 |
7490 if (CausedFocusEvent.Cause.ACTIVATION == cause) { |
7490 if (CausedFocusEvent.Cause.ACTIVATION == cause) { |
7492 // in activation. We do request focus on component which |
7492 // in activation. We do request focus on component which |
7493 // has got temporary focus lost and then on component which is |
7493 // has got temporary focus lost and then on component which is |
7494 // most recent focus owner. But most recent focus owner can be |
7494 // most recent focus owner. But most recent focus owner can be |
7495 // changed by requestFocsuXXX() call only, so this transfer has |
7495 // changed by requestFocsuXXX() call only, so this transfer has |
7496 // been already approved. |
7496 // been already approved. |
7497 if (focusLog.isLoggable(Level.FINEST)) { |
7497 if (focusLog.isLoggable(PlatformLogger.FINEST)) { |
7498 focusLog.log(Level.FINEST, "cause is activation"); |
7498 focusLog.finest("cause is activation"); |
7499 } |
7499 } |
7500 return true; |
7500 return true; |
7501 } |
7501 } |
7502 |
7502 |
7503 boolean ret = Component.requestFocusController.acceptRequestFocus(focusOwner, |
7503 boolean ret = Component.requestFocusController.acceptRequestFocus(focusOwner, |
7504 this, |
7504 this, |
7505 temporary, |
7505 temporary, |
7506 focusedWindowChangeAllowed, |
7506 focusedWindowChangeAllowed, |
7507 cause); |
7507 cause); |
7508 if (focusLog.isLoggable(Level.FINEST)) { |
7508 if (focusLog.isLoggable(PlatformLogger.FINEST)) { |
7509 focusLog.log(Level.FINEST, "RequestFocusController returns {0}", ret); |
7509 focusLog.finest("RequestFocusController returns {0}", ret); |
7510 } |
7510 } |
7511 |
7511 |
7512 return ret; |
7512 return ret; |
7513 } |
7513 } |
7514 |
7514 |
7595 public void nextFocus() { |
7595 public void nextFocus() { |
7596 transferFocus(false); |
7596 transferFocus(false); |
7597 } |
7597 } |
7598 |
7598 |
7599 boolean transferFocus(boolean clearOnFailure) { |
7599 boolean transferFocus(boolean clearOnFailure) { |
7600 if (focusLog.isLoggable(Level.FINER)) { |
7600 if (focusLog.isLoggable(PlatformLogger.FINER)) { |
7601 focusLog.finer("clearOnFailure = " + clearOnFailure); |
7601 focusLog.finer("clearOnFailure = " + clearOnFailure); |
7602 } |
7602 } |
7603 Component toFocus = getNextFocusCandidate(); |
7603 Component toFocus = getNextFocusCandidate(); |
7604 boolean res = false; |
7604 boolean res = false; |
7605 if (toFocus != null && !toFocus.isFocusOwner() && toFocus != this) { |
7605 if (toFocus != null && !toFocus.isFocusOwner() && toFocus != this) { |
7606 res = toFocus.requestFocusInWindow(CausedFocusEvent.Cause.TRAVERSAL_FORWARD); |
7606 res = toFocus.requestFocusInWindow(CausedFocusEvent.Cause.TRAVERSAL_FORWARD); |
7607 } |
7607 } |
7608 if (clearOnFailure && !res) { |
7608 if (clearOnFailure && !res) { |
7609 if (focusLog.isLoggable(Level.FINER)) { |
7609 if (focusLog.isLoggable(PlatformLogger.FINER)) { |
7610 focusLog.finer("clear global focus owner"); |
7610 focusLog.finer("clear global focus owner"); |
7611 } |
7611 } |
7612 KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); |
7612 KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); |
7613 } |
7613 } |
7614 if (focusLog.isLoggable(Level.FINER)) { |
7614 if (focusLog.isLoggable(PlatformLogger.FINER)) { |
7615 focusLog.finer("returning result: " + res); |
7615 focusLog.finer("returning result: " + res); |
7616 } |
7616 } |
7617 return res; |
7617 return res; |
7618 } |
7618 } |
7619 |
7619 |
7624 !(rootAncestor.isShowing() && rootAncestor.canBeFocusOwner())) |
7624 !(rootAncestor.isShowing() && rootAncestor.canBeFocusOwner())) |
7625 { |
7625 { |
7626 comp = rootAncestor; |
7626 comp = rootAncestor; |
7627 rootAncestor = comp.getFocusCycleRootAncestor(); |
7627 rootAncestor = comp.getFocusCycleRootAncestor(); |
7628 } |
7628 } |
7629 if (focusLog.isLoggable(Level.FINER)) { |
7629 if (focusLog.isLoggable(PlatformLogger.FINER)) { |
7630 focusLog.finer("comp = " + comp + ", root = " + rootAncestor); |
7630 focusLog.finer("comp = " + comp + ", root = " + rootAncestor); |
7631 } |
7631 } |
7632 Component candidate = null; |
7632 Component candidate = null; |
7633 if (rootAncestor != null) { |
7633 if (rootAncestor != null) { |
7634 FocusTraversalPolicy policy = rootAncestor.getFocusTraversalPolicy(); |
7634 FocusTraversalPolicy policy = rootAncestor.getFocusTraversalPolicy(); |
7635 Component toFocus = policy.getComponentAfter(rootAncestor, comp); |
7635 Component toFocus = policy.getComponentAfter(rootAncestor, comp); |
7636 if (focusLog.isLoggable(Level.FINER)) { |
7636 if (focusLog.isLoggable(PlatformLogger.FINER)) { |
7637 focusLog.finer("component after is " + toFocus); |
7637 focusLog.finer("component after is " + toFocus); |
7638 } |
7638 } |
7639 if (toFocus == null) { |
7639 if (toFocus == null) { |
7640 toFocus = policy.getDefaultComponent(rootAncestor); |
7640 toFocus = policy.getDefaultComponent(rootAncestor); |
7641 if (focusLog.isLoggable(Level.FINER)) { |
7641 if (focusLog.isLoggable(PlatformLogger.FINER)) { |
7642 focusLog.finer("default component is " + toFocus); |
7642 focusLog.finer("default component is " + toFocus); |
7643 } |
7643 } |
7644 } |
7644 } |
7645 if (toFocus == null) { |
7645 if (toFocus == null) { |
7646 Applet applet = EmbeddedFrame.getAppletIfAncestorOf(this); |
7646 Applet applet = EmbeddedFrame.getAppletIfAncestorOf(this); |
7685 if (toFocus != null) { |
7685 if (toFocus != null) { |
7686 res = toFocus.requestFocusInWindow(CausedFocusEvent.Cause.TRAVERSAL_BACKWARD); |
7686 res = toFocus.requestFocusInWindow(CausedFocusEvent.Cause.TRAVERSAL_BACKWARD); |
7687 } |
7687 } |
7688 } |
7688 } |
7689 if (!res) { |
7689 if (!res) { |
7690 if (focusLog.isLoggable(Level.FINER)) { |
7690 if (focusLog.isLoggable(PlatformLogger.FINER)) { |
7691 focusLog.finer("clear global focus owner"); |
7691 focusLog.finer("clear global focus owner"); |
7692 } |
7692 } |
7693 KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); |
7693 KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); |
7694 } |
7694 } |
7695 if (focusLog.isLoggable(Level.FINER)) { |
7695 if (focusLog.isLoggable(PlatformLogger.FINER)) { |
7696 focusLog.finer("returning result: " + res); |
7696 focusLog.finer("returning result: " + res); |
7697 } |
7697 } |
7698 return res; |
7698 return res; |
7699 } |
7699 } |
7700 |
7700 |
9482 if (shape.equals(getAppliedShape())) { |
9482 if (shape.equals(getAppliedShape())) { |
9483 return; |
9483 return; |
9484 } |
9484 } |
9485 this.compoundShape = shape; |
9485 this.compoundShape = shape; |
9486 Point compAbsolute = getLocationOnWindow(); |
9486 Point compAbsolute = getLocationOnWindow(); |
9487 if (mixingLog.isLoggable(Level.FINER)) { |
9487 if (mixingLog.isLoggable(PlatformLogger.FINER)) { |
9488 mixingLog.fine("this = " + this + |
9488 mixingLog.fine("this = " + this + |
9489 "; compAbsolute=" + compAbsolute + "; shape=" + shape); |
9489 "; compAbsolute=" + compAbsolute + "; shape=" + shape); |
9490 } |
9490 } |
9491 peer.applyShape(shape.getTranslatedRegion(-compAbsolute.x, -compAbsolute.y)); |
9491 peer.applyShape(shape.getTranslatedRegion(-compAbsolute.x, -compAbsolute.y)); |
9492 } |
9492 } |
9616 |
9616 |
9617 private Region calculateCurrentShape() { |
9617 private Region calculateCurrentShape() { |
9618 checkTreeLock(); |
9618 checkTreeLock(); |
9619 Region s = getNormalShape(); |
9619 Region s = getNormalShape(); |
9620 |
9620 |
9621 if (mixingLog.isLoggable(Level.FINE)) { |
9621 if (mixingLog.isLoggable(PlatformLogger.FINE)) { |
9622 mixingLog.fine("this = " + this + "; normalShape=" + s); |
9622 mixingLog.fine("this = " + this + "; normalShape=" + s); |
9623 } |
9623 } |
9624 |
9624 |
9625 if (getContainer() != null) { |
9625 if (getContainer() != null) { |
9626 Component comp = this; |
9626 Component comp = this; |
9650 comp = cont; |
9650 comp = cont; |
9651 cont = cont.getContainer(); |
9651 cont = cont.getContainer(); |
9652 } |
9652 } |
9653 } |
9653 } |
9654 |
9654 |
9655 if (mixingLog.isLoggable(Level.FINE)) { |
9655 if (mixingLog.isLoggable(PlatformLogger.FINE)) { |
9656 mixingLog.fine("currentShape=" + s); |
9656 mixingLog.fine("currentShape=" + s); |
9657 } |
9657 } |
9658 |
9658 |
9659 return s; |
9659 return s; |
9660 } |
9660 } |
9661 |
9661 |
9662 void applyCurrentShape() { |
9662 void applyCurrentShape() { |
9663 checkTreeLock(); |
9663 checkTreeLock(); |
9664 if (!areBoundsValid()) { |
9664 if (!areBoundsValid()) { |
9665 if (mixingLog.isLoggable(Level.FINE)) { |
9665 if (mixingLog.isLoggable(PlatformLogger.FINE)) { |
9666 mixingLog.fine("this = " + this + "; areBoundsValid = " + areBoundsValid()); |
9666 mixingLog.fine("this = " + this + "; areBoundsValid = " + areBoundsValid()); |
9667 } |
9667 } |
9668 return; // Because applyCompoundShape() ignores such components anyway |
9668 return; // Because applyCompoundShape() ignores such components anyway |
9669 } |
9669 } |
9670 if (mixingLog.isLoggable(Level.FINE)) { |
9670 if (mixingLog.isLoggable(PlatformLogger.FINE)) { |
9671 mixingLog.fine("this = " + this); |
9671 mixingLog.fine("this = " + this); |
9672 } |
9672 } |
9673 applyCompoundShape(calculateCurrentShape()); |
9673 applyCompoundShape(calculateCurrentShape()); |
9674 } |
9674 } |
9675 |
9675 |
9676 final void subtractAndApplyShape(Region s) { |
9676 final void subtractAndApplyShape(Region s) { |
9677 checkTreeLock(); |
9677 checkTreeLock(); |
9678 |
9678 |
9679 if (mixingLog.isLoggable(Level.FINE)) { |
9679 if (mixingLog.isLoggable(PlatformLogger.FINE)) { |
9680 mixingLog.fine("this = " + this + "; s=" + s); |
9680 mixingLog.fine("this = " + this + "; s=" + s); |
9681 } |
9681 } |
9682 |
9682 |
9683 applyCompoundShape(getAppliedShape().getDifference(s)); |
9683 applyCompoundShape(getAppliedShape().getDifference(s)); |
9684 } |
9684 } |
9739 |
9739 |
9740 void mixOnHiding(boolean isLightweight) { |
9740 void mixOnHiding(boolean isLightweight) { |
9741 // We cannot be sure that the peer exists at this point, so we need the argument |
9741 // We cannot be sure that the peer exists at this point, so we need the argument |
9742 // to find out whether the hiding component is (well, actually was) a LW or a HW. |
9742 // to find out whether the hiding component is (well, actually was) a LW or a HW. |
9743 synchronized (getTreeLock()) { |
9743 synchronized (getTreeLock()) { |
9744 if (mixingLog.isLoggable(Level.FINE)) { |
9744 if (mixingLog.isLoggable(PlatformLogger.FINE)) { |
9745 mixingLog.fine("this = " + this + "; isLightweight = " + isLightweight); |
9745 mixingLog.fine("this = " + this + "; isLightweight = " + isLightweight); |
9746 } |
9746 } |
9747 if (!isMixingNeeded()) { |
9747 if (!isMixingNeeded()) { |
9748 return; |
9748 return; |
9749 } |
9749 } |
9772 void mixOnZOrderChanging(int oldZorder, int newZorder) { |
9772 void mixOnZOrderChanging(int oldZorder, int newZorder) { |
9773 synchronized (getTreeLock()) { |
9773 synchronized (getTreeLock()) { |
9774 boolean becameHigher = newZorder < oldZorder; |
9774 boolean becameHigher = newZorder < oldZorder; |
9775 Container parent = getContainer(); |
9775 Container parent = getContainer(); |
9776 |
9776 |
9777 if (mixingLog.isLoggable(Level.FINE)) { |
9777 if (mixingLog.isLoggable(PlatformLogger.FINE)) { |
9778 mixingLog.fine("this = " + this + |
9778 mixingLog.fine("this = " + this + |
9779 "; oldZorder=" + oldZorder + "; newZorder=" + newZorder + "; parent=" + parent); |
9779 "; oldZorder=" + oldZorder + "; newZorder=" + newZorder + "; parent=" + parent); |
9780 } |
9780 } |
9781 if (!isMixingNeeded()) { |
9781 if (!isMixingNeeded()) { |
9782 return; |
9782 return; |
9816 // non-container components don't need to handle validation. |
9816 // non-container components don't need to handle validation. |
9817 } |
9817 } |
9818 |
9818 |
9819 final boolean isMixingNeeded() { |
9819 final boolean isMixingNeeded() { |
9820 if (SunToolkit.getSunAwtDisableMixing()) { |
9820 if (SunToolkit.getSunAwtDisableMixing()) { |
9821 if (mixingLog.isLoggable(Level.FINEST)) { |
9821 if (mixingLog.isLoggable(PlatformLogger.FINEST)) { |
9822 mixingLog.finest("this = " + this + "; Mixing disabled via sun.awt.disableMixing"); |
9822 mixingLog.finest("this = " + this + "; Mixing disabled via sun.awt.disableMixing"); |
9823 } |
9823 } |
9824 return false; |
9824 return false; |
9825 } |
9825 } |
9826 if (!areBoundsValid()) { |
9826 if (!areBoundsValid()) { |
9827 if (mixingLog.isLoggable(Level.FINE)) { |
9827 if (mixingLog.isLoggable(PlatformLogger.FINE)) { |
9828 mixingLog.fine("this = " + this + "; areBoundsValid = " + areBoundsValid()); |
9828 mixingLog.fine("this = " + this + "; areBoundsValid = " + areBoundsValid()); |
9829 } |
9829 } |
9830 return false; |
9830 return false; |
9831 } |
9831 } |
9832 Window window = getContainingWindow(); |
9832 Window window = getContainingWindow(); |
9833 if (window != null) { |
9833 if (window != null) { |
9834 if (!window.hasHeavyweightDescendants() || !window.hasLightweightDescendants()) { |
9834 if (!window.hasHeavyweightDescendants() || !window.hasLightweightDescendants()) { |
9835 if (mixingLog.isLoggable(Level.FINE)) { |
9835 if (mixingLog.isLoggable(PlatformLogger.FINE)) { |
9836 mixingLog.fine("containing window = " + window + |
9836 mixingLog.fine("containing window = " + window + |
9837 "; has h/w descendants = " + window.hasHeavyweightDescendants() + |
9837 "; has h/w descendants = " + window.hasHeavyweightDescendants() + |
9838 "; has l/w descendants = " + window.hasLightweightDescendants()); |
9838 "; has l/w descendants = " + window.hasLightweightDescendants()); |
9839 } |
9839 } |
9840 return false; |
9840 return false; |
9841 } |
9841 } |
9842 } else { |
9842 } else { |
9843 if (mixingLog.isLoggable(Level.FINE)) { |
9843 if (mixingLog.isLoggable(PlatformLogger.FINE)) { |
9844 mixingLog.finest("this = " + this + "; containing window is null"); |
9844 mixingLog.fine("this = " + this + "; containing window is null"); |
9845 } |
9845 } |
9846 return false; |
9846 return false; |
9847 } |
9847 } |
9848 return true; |
9848 return true; |
9849 } |
9849 } |