jdk/src/share/classes/java/awt/Container.java

Print this page

        

@@ -159,11 +159,11 @@
      * @see #setFocusTraversalPolicyProvider
      */
     private boolean focusTraversalPolicyProvider;
 
     // keeps track of the threads that are printing this component
-    private transient Set printingThreads;
+    private transient Set<Thread> printingThreads;
     // True if there is at least one thread that's printing this component
     private transient boolean printing = false;
 
     transient ContainerListener containerListener;
 

@@ -273,11 +273,11 @@
      * somewhere higher up in the component tree that is native.
      * (such as Frame for example).
      */
     public Container() {
     }
-
+    @SuppressWarnings({"unchecked","rawtypes"})
     void initializeFocusTraversalKeys() {
         focusTraversalKeys = new Set[4];
     }
 
     /**

@@ -792,11 +792,11 @@
                 if (comp instanceof Container) {
                     reparentTraverse(parentPeer, (Container)comp);
                 }
             } else {
                 // Q: Need to update NativeInLightFixer?
-                comp.getPeer().reparent(parentPeer);
+                comp.peer.reparent(parentPeer);
             }
         }
     }
 
     /**

@@ -811,14 +811,14 @@
         }
         if (comp.isLightweight()) {
             // If component is lightweight container we need to reparent all its explicit  heavyweight children
             if (comp instanceof Container) {
                 // Traverse component's tree till depth-first until encountering heavyweight component
-                reparentTraverse((ContainerPeer)getPeer(), (Container)comp);
+                reparentTraverse((ContainerPeer)peer, (Container)comp);
             }
         } else {
-            comp.getPeer().reparent((ContainerPeer)getPeer());
+            comp.peer.reparent((ContainerPeer)peer);
         }
     }
 
     /**
      * Adds component to this container. Tries to minimize side effects of this adding -

@@ -2004,11 +2004,11 @@
         if (isShowing()) {
             Thread t = Thread.currentThread();
             try {
                 synchronized (getObjectLock()) {
                     if (printingThreads == null) {
-                        printingThreads = new HashSet();
+                        printingThreads = new HashSet<>();
                     }
                     printingThreads.add(t);
                     printing = true;
                 }
                 super.print(g);  // By default, Component.print() calls paint()

@@ -2146,11 +2146,11 @@
      * @see #addContainerListener
      * @see #removeContainerListener
      * @since 1.4
      */
     public synchronized ContainerListener[] getContainerListeners() {
-        return (ContainerListener[]) (getListeners(ContainerListener.class));
+        return getListeners(ContainerListener.class);
     }
 
     /**
      * Returns an array of all the objects currently registered
      * as <code><em>Foo</em>Listener</code>s

@@ -2597,13 +2597,13 @@
      */
     public Point getMousePosition(boolean allowChildren) throws HeadlessException {
         if (GraphicsEnvironment.isHeadless()) {
             throw new HeadlessException();
         }
-        PointerInfo pi = (PointerInfo)java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction() {
-                public Object run() {
+        PointerInfo pi = java.security.AccessController.doPrivileged(
+            new java.security.PrivilegedAction<PointerInfo>() {
+                public PointerInfo run() {
                     return MouseInfo.getPointerInfo();
                 }
             }
         );
         synchronized (getTreeLock()) {

@@ -2680,11 +2680,11 @@
                 if (comp instanceof Container) {
                     comp = ((Container)comp).findComponentAtImpl(x - comp.x,
                                                                  y - comp.y,
                                                                  ignoreEnabled);
                 } else {
-                    comp = comp.locate(x - comp.x, y - comp.y);
+                    comp = comp.getComponentAt(x - comp.x, y - comp.y);
                 }
                 if (comp != null && comp.visible &&
                     (ignoreEnabled || comp.enabled))
                 {
                     return comp;

@@ -2698,11 +2698,11 @@
                 if (comp instanceof Container) {
                     comp = ((Container)comp).findComponentAtImpl(x - comp.x,
                                                                  y - comp.y,
                                                                  ignoreEnabled);
                 } else {
-                    comp = comp.locate(x - comp.x, y - comp.y);
+                    comp = comp.getComponentAt(x - comp.x, y - comp.y);
                 }
                 if (comp != null && comp.visible &&
                     (ignoreEnabled || comp.enabled))
                 {
                     return comp;

@@ -4150,13 +4150,12 @@
                 if  (comp instanceof Container) {
                     ((Container)comp).recursiveShowHeavyweightChildren();
                 }
             } else {
                 if (comp.isVisible()) {
-                    ComponentPeer peer = comp.getPeer();
-                    if (peer != null) {
-                        peer.setVisible(true);
+                    if (comp.peer != null) {
+                        comp.peer.setVisible(true);
                     }
                 }
             }
         }
     }

@@ -4171,13 +4170,12 @@
                 if  (comp instanceof Container) {
                     ((Container)comp).recursiveHideHeavyweightChildren();
                 }
             } else {
                 if (comp.isVisible()) {
-                    ComponentPeer peer = comp.getPeer();
-                    if (peer != null) {
-                        peer.setVisible(false);
+                    if (comp.peer != null) {
+                        comp.peer.setVisible(false);
                     }
                 }
             }
         }
     }

@@ -4192,13 +4190,12 @@
                     final Point newOrigin = new Point(origin);
                     newOrigin.translate(comp.getX(), comp.getY());
                     ((Container)comp).recursiveRelocateHeavyweightChildren(newOrigin);
                 }
             } else {
-                ComponentPeer peer = comp.getPeer();
-                if (peer != null) {
-                    peer.setBounds(origin.x + comp.getX(), origin.y + comp.getY(),
+                if (comp.peer != null) {
+                    comp.peer.setBounds(origin.x + comp.getX(), origin.y + comp.getY(),
                             comp.getWidth(), comp.getHeight(),
                             ComponentPeer.SET_LOCATION);
                 }
             }
         }

@@ -4635,11 +4632,11 @@
      * events in this container
      */
     private void startListeningForOtherDrags() {
         //System.out.println("Adding AWTEventListener");
         java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction() {
+            new java.security.PrivilegedAction<Object>() {
                 public Object run() {
                     nativeContainer.getToolkit().addAWTEventListener(
                         LightweightDispatcher.this,
                         AWTEvent.MOUSE_EVENT_MASK |
                         AWTEvent.MOUSE_MOTION_EVENT_MASK);

@@ -4650,11 +4647,11 @@
     }
 
     private void stopListeningForOtherDrags() {
         //System.out.println("Removing AWTEventListener");
         java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction() {
+            new java.security.PrivilegedAction<Object>() {
                 public Object run() {
                     nativeContainer.getToolkit().removeAWTEventListener(LightweightDispatcher.this);
                     return null;
                 }
             }