equal
deleted
inserted
replaced
159 * @see #setFocusTraversalPolicyProvider |
159 * @see #setFocusTraversalPolicyProvider |
160 */ |
160 */ |
161 private boolean focusTraversalPolicyProvider; |
161 private boolean focusTraversalPolicyProvider; |
162 |
162 |
163 // keeps track of the threads that are printing this component |
163 // keeps track of the threads that are printing this component |
164 private transient Set printingThreads; |
164 private transient Set<Thread> printingThreads; |
165 // True if there is at least one thread that's printing this component |
165 // True if there is at least one thread that's printing this component |
166 private transient boolean printing = false; |
166 private transient boolean printing = false; |
167 |
167 |
168 transient ContainerListener containerListener; |
168 transient ContainerListener containerListener; |
169 |
169 |
273 * somewhere higher up in the component tree that is native. |
273 * somewhere higher up in the component tree that is native. |
274 * (such as Frame for example). |
274 * (such as Frame for example). |
275 */ |
275 */ |
276 public Container() { |
276 public Container() { |
277 } |
277 } |
278 |
278 @SuppressWarnings({"unchecked","rawtypes"}) |
279 void initializeFocusTraversalKeys() { |
279 void initializeFocusTraversalKeys() { |
280 focusTraversalKeys = new Set[4]; |
280 focusTraversalKeys = new Set[4]; |
281 } |
281 } |
282 |
282 |
283 /** |
283 /** |
2004 if (isShowing()) { |
2004 if (isShowing()) { |
2005 Thread t = Thread.currentThread(); |
2005 Thread t = Thread.currentThread(); |
2006 try { |
2006 try { |
2007 synchronized (getObjectLock()) { |
2007 synchronized (getObjectLock()) { |
2008 if (printingThreads == null) { |
2008 if (printingThreads == null) { |
2009 printingThreads = new HashSet(); |
2009 printingThreads = new HashSet<>(); |
2010 } |
2010 } |
2011 printingThreads.add(t); |
2011 printingThreads.add(t); |
2012 printing = true; |
2012 printing = true; |
2013 } |
2013 } |
2014 super.print(g); // By default, Component.print() calls paint() |
2014 super.print(g); // By default, Component.print() calls paint() |
2146 * @see #addContainerListener |
2146 * @see #addContainerListener |
2147 * @see #removeContainerListener |
2147 * @see #removeContainerListener |
2148 * @since 1.4 |
2148 * @since 1.4 |
2149 */ |
2149 */ |
2150 public synchronized ContainerListener[] getContainerListeners() { |
2150 public synchronized ContainerListener[] getContainerListeners() { |
2151 return (ContainerListener[]) (getListeners(ContainerListener.class)); |
2151 return getListeners(ContainerListener.class); |
2152 } |
2152 } |
2153 |
2153 |
2154 /** |
2154 /** |
2155 * Returns an array of all the objects currently registered |
2155 * Returns an array of all the objects currently registered |
2156 * as <code><em>Foo</em>Listener</code>s |
2156 * as <code><em>Foo</em>Listener</code>s |
2597 */ |
2597 */ |
2598 public Point getMousePosition(boolean allowChildren) throws HeadlessException { |
2598 public Point getMousePosition(boolean allowChildren) throws HeadlessException { |
2599 if (GraphicsEnvironment.isHeadless()) { |
2599 if (GraphicsEnvironment.isHeadless()) { |
2600 throw new HeadlessException(); |
2600 throw new HeadlessException(); |
2601 } |
2601 } |
2602 PointerInfo pi = (PointerInfo)java.security.AccessController.doPrivileged( |
2602 PointerInfo pi = java.security.AccessController.doPrivileged( |
2603 new java.security.PrivilegedAction() { |
2603 new java.security.PrivilegedAction<PointerInfo>() { |
2604 public Object run() { |
2604 public PointerInfo run() { |
2605 return MouseInfo.getPointerInfo(); |
2605 return MouseInfo.getPointerInfo(); |
2606 } |
2606 } |
2607 } |
2607 } |
2608 ); |
2608 ); |
2609 synchronized (getTreeLock()) { |
2609 synchronized (getTreeLock()) { |
2680 if (comp instanceof Container) { |
2680 if (comp instanceof Container) { |
2681 comp = ((Container)comp).findComponentAtImpl(x - comp.x, |
2681 comp = ((Container)comp).findComponentAtImpl(x - comp.x, |
2682 y - comp.y, |
2682 y - comp.y, |
2683 ignoreEnabled); |
2683 ignoreEnabled); |
2684 } else { |
2684 } else { |
2685 comp = comp.locate(x - comp.x, y - comp.y); |
2685 comp = comp.getComponentAt(x - comp.x, y - comp.y); |
2686 } |
2686 } |
2687 if (comp != null && comp.visible && |
2687 if (comp != null && comp.visible && |
2688 (ignoreEnabled || comp.enabled)) |
2688 (ignoreEnabled || comp.enabled)) |
2689 { |
2689 { |
2690 return comp; |
2690 return comp; |
2698 if (comp instanceof Container) { |
2698 if (comp instanceof Container) { |
2699 comp = ((Container)comp).findComponentAtImpl(x - comp.x, |
2699 comp = ((Container)comp).findComponentAtImpl(x - comp.x, |
2700 y - comp.y, |
2700 y - comp.y, |
2701 ignoreEnabled); |
2701 ignoreEnabled); |
2702 } else { |
2702 } else { |
2703 comp = comp.locate(x - comp.x, y - comp.y); |
2703 comp = comp.getComponentAt(x - comp.x, y - comp.y); |
2704 } |
2704 } |
2705 if (comp != null && comp.visible && |
2705 if (comp != null && comp.visible && |
2706 (ignoreEnabled || comp.enabled)) |
2706 (ignoreEnabled || comp.enabled)) |
2707 { |
2707 { |
2708 return comp; |
2708 return comp; |
4635 * events in this container |
4635 * events in this container |
4636 */ |
4636 */ |
4637 private void startListeningForOtherDrags() { |
4637 private void startListeningForOtherDrags() { |
4638 //System.out.println("Adding AWTEventListener"); |
4638 //System.out.println("Adding AWTEventListener"); |
4639 java.security.AccessController.doPrivileged( |
4639 java.security.AccessController.doPrivileged( |
4640 new java.security.PrivilegedAction() { |
4640 new java.security.PrivilegedAction<Object>() { |
4641 public Object run() { |
4641 public Object run() { |
4642 nativeContainer.getToolkit().addAWTEventListener( |
4642 nativeContainer.getToolkit().addAWTEventListener( |
4643 LightweightDispatcher.this, |
4643 LightweightDispatcher.this, |
4644 AWTEvent.MOUSE_EVENT_MASK | |
4644 AWTEvent.MOUSE_EVENT_MASK | |
4645 AWTEvent.MOUSE_MOTION_EVENT_MASK); |
4645 AWTEvent.MOUSE_MOTION_EVENT_MASK); |
4650 } |
4650 } |
4651 |
4651 |
4652 private void stopListeningForOtherDrags() { |
4652 private void stopListeningForOtherDrags() { |
4653 //System.out.println("Removing AWTEventListener"); |
4653 //System.out.println("Removing AWTEventListener"); |
4654 java.security.AccessController.doPrivileged( |
4654 java.security.AccessController.doPrivileged( |
4655 new java.security.PrivilegedAction() { |
4655 new java.security.PrivilegedAction<Object>() { |
4656 public Object run() { |
4656 public Object run() { |
4657 nativeContainer.getToolkit().removeAWTEventListener(LightweightDispatcher.this); |
4657 nativeContainer.getToolkit().removeAWTEventListener(LightweightDispatcher.this); |
4658 return null; |
4658 return null; |
4659 } |
4659 } |
4660 } |
4660 } |