src/java.desktop/share/classes/java/awt/Component.java

Print this page

        

*** 59,68 **** --- 59,69 ---- import java.security.PrivilegedAction; import java.security.AccessControlContext; import javax.accessibility.*; import java.applet.Applet; + import sun.awt.ComponentFactory; import sun.security.action.GetPropertyAction; import sun.awt.AppContext; import sun.awt.AWTAccessor; import sun.awt.ConstrainableGraphics; import sun.awt.SubRegionShowable;
*** 1227,1236 **** --- 1228,1245 ---- return parent.getToolkitImpl(); } return Toolkit.getDefaultToolkit(); } + final ComponentFactory getComponentFactory() { + final Toolkit toolkit = getToolkit(); + if (toolkit instanceof ComponentFactory) { + return (ComponentFactory) toolkit; + } + throw new AWTError("Unsupported toolkit: " + toolkit); + } + /** * Determines whether this component is valid. A component is valid * when it is correctly sized and positioned within its parent * container and all its children are also valid. * In order to account for peers' size requirements, components are invalidated
*** 1324,1334 **** Component findUnderMouseInWindow(PointerInfo pi) { if (!isShowing()) { return null; } Window win = getContainingWindow(); ! if (!Toolkit.getDefaultToolkit().getMouseInfoPeer().isWindowUnderMouse(win)) { return null; } final boolean INCLUDE_DISABLED = true; Point relativeToWindow = win.pointRelativeToComponent(pi.getLocation()); Component inTheSameWindow = win.findComponentAt(relativeToWindow.x, --- 1333,1347 ---- Component findUnderMouseInWindow(PointerInfo pi) { if (!isShowing()) { return null; } Window win = getContainingWindow(); ! Toolkit toolkit = Toolkit.getDefaultToolkit(); ! if (!(toolkit instanceof ComponentFactory)) { ! return null; ! } ! if (!((ComponentFactory) toolkit).getMouseInfoPeer().isWindowUnderMouse(win)) { return null; } final boolean INCLUDE_DISABLED = true; Point relativeToWindow = win.pointRelativeToComponent(pi.getLocation()); Component inTheSameWindow = win.findComponentAt(relativeToWindow.x,
*** 6955,6965 **** ComponentPeer peer = this.peer; if (peer == null || peer instanceof LightweightPeer){ if (peer == null) { // Update both the Component's peer variable and the local // variable we use for thread safety. ! this.peer = peer = getToolkit().createComponent(this); } // This is a lightweight component which means it won't be // able to get window-related events by itself. If any // have been enabled, then the nearest native container must --- 6968,6978 ---- ComponentPeer peer = this.peer; if (peer == null || peer instanceof LightweightPeer){ if (peer == null) { // Update both the Component's peer variable and the local // variable we use for thread safety. ! this.peer = peer = getComponentFactory().createComponent(this); } // This is a lightweight component which means it won't be // able to get window-related events by itself. If any // have been enabled, then the nearest native container must