src/share/classes/javax/swing/plaf/metal/MetalToolBarUI.java

Print this page




 100     /**
 101      * Unregisters the specified component.
 102      */
 103     synchronized static void unregister(JComponent c) {
 104         for (int counter = components.size() - 1; counter >= 0; counter--) {
 105             // Search for the component, removing any flushed references
 106             // along the way.
 107             JComponent target = components.get(counter).get();
 108 
 109             if (target == c || target == null) {
 110                 components.remove(counter);
 111             }
 112         }
 113     }
 114 
 115     /**
 116      * Finds a previously registered component of class <code>target</code>
 117      * that shares the JRootPane ancestor of <code>from</code>.
 118      */
 119     synchronized static Object findRegisteredComponentOfType(JComponent from,
 120                                                              Class target) {
 121         JRootPane rp = SwingUtilities.getRootPane(from);
 122         if (rp != null) {
 123             for (int counter = components.size() - 1; counter >= 0; counter--){
 124                 Object component = ((WeakReference)components.get(counter)).
 125                                    get();
 126 
 127                 if (component == null) {
 128                     // WeakReference has gone away, remove the WeakReference
 129                     components.remove(counter);
 130                 }
 131                 else if (target.isInstance(component) && SwingUtilities.
 132                          getRootPane((Component)component) == rp) {
 133                     return component;
 134                 }
 135             }
 136         }
 137         return null;
 138     }
 139 
 140     /**




 100     /**
 101      * Unregisters the specified component.
 102      */
 103     synchronized static void unregister(JComponent c) {
 104         for (int counter = components.size() - 1; counter >= 0; counter--) {
 105             // Search for the component, removing any flushed references
 106             // along the way.
 107             JComponent target = components.get(counter).get();
 108 
 109             if (target == c || target == null) {
 110                 components.remove(counter);
 111             }
 112         }
 113     }
 114 
 115     /**
 116      * Finds a previously registered component of class <code>target</code>
 117      * that shares the JRootPane ancestor of <code>from</code>.
 118      */
 119     synchronized static Object findRegisteredComponentOfType(JComponent from,
 120                                                              Class<?> target) {
 121         JRootPane rp = SwingUtilities.getRootPane(from);
 122         if (rp != null) {
 123             for (int counter = components.size() - 1; counter >= 0; counter--){
 124                 Object component = ((WeakReference)components.get(counter)).
 125                                    get();
 126 
 127                 if (component == null) {
 128                     // WeakReference has gone away, remove the WeakReference
 129                     components.remove(counter);
 130                 }
 131                 else if (target.isInstance(component) && SwingUtilities.
 132                          getRootPane((Component)component) == rp) {
 133                     return component;
 134                 }
 135             }
 136         }
 137         return null;
 138     }
 139 
 140     /**