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

Print this page




 955             }
 956             public Color getForeground(Component comp) {
 957                 return comp.foreground;
 958             }
 959             public Color getBackground(Component comp) {
 960                 return comp.background;
 961             }
 962             public void setBackground(Component comp, Color background) {
 963                 comp.background = background;
 964             }
 965             public Font getFont(Component comp) {
 966                 return comp.getFont_NoClientCode();
 967             }
 968             public void processEvent(Component comp, AWTEvent e) {
 969                 comp.processEvent(e);
 970             }
 971 
 972             public AccessControlContext getAccessControlContext(Component comp) {
 973                 return comp.getAccessControlContext();
 974             }




 975         });
 976     }
 977 
 978     /**
 979      * Constructs a new component. Class <code>Component</code> can be
 980      * extended directly to create a lightweight component that does not
 981      * utilize an opaque native window. A lightweight component must be
 982      * hosted by a native container somewhere higher up in the component
 983      * tree (for example, by a <code>Frame</code> object).
 984      */
 985     protected Component() {
 986         appContext = AppContext.getAppContext();
 987     }
 988 
 989     @SuppressWarnings({"rawtypes", "unchecked"})
 990     void initializeFocusTraversalKeys() {
 991         focusTraversalKeys = new Set[3];
 992     }
 993 
 994     /**


2960         }
2961     }
2962 
2963     /**
2964      * Revalidates the component hierarchy up to the nearest validate root.
2965      * <p>
2966      * This method first invalidates the component hierarchy starting from this
2967      * component up to the nearest validate root. Afterwards, the component
2968      * hierarchy is validated starting from the nearest validate root.
2969      * <p>
2970      * This is a convenience method supposed to help application developers
2971      * avoid looking for validate roots manually. Basically, it's equivalent to
2972      * first calling the {@link #invalidate()} method on this component, and
2973      * then calling the {@link #validate()} method on the nearest validate
2974      * root.
2975      *
2976      * @see Container#isValidateRoot
2977      * @since 1.7
2978      */
2979     public void revalidate() {







2980         synchronized (getTreeLock()) {
2981             invalidate();
2982 
2983             Container root = getContainer();
2984             if (root == null) {
2985                 // There's no parents. Just validate itself.
2986                 validate();
2987             } else {
2988                 while (!root.isValidateRoot()) {
2989                     if (root.getContainer() == null) {
2990                         // If there's no validate roots, we'll validate the
2991                         // topmost container
2992                         break;
2993                     }
2994 
2995                     root = root.getContainer();
2996                 }
2997 
2998                 root.validate();
2999             }




 955             }
 956             public Color getForeground(Component comp) {
 957                 return comp.foreground;
 958             }
 959             public Color getBackground(Component comp) {
 960                 return comp.background;
 961             }
 962             public void setBackground(Component comp, Color background) {
 963                 comp.background = background;
 964             }
 965             public Font getFont(Component comp) {
 966                 return comp.getFont_NoClientCode();
 967             }
 968             public void processEvent(Component comp, AWTEvent e) {
 969                 comp.processEvent(e);
 970             }
 971 
 972             public AccessControlContext getAccessControlContext(Component comp) {
 973                 return comp.getAccessControlContext();
 974             }
 975 
 976             public void revalidateSynchronously(Component comp) {
 977                 comp.revalidateSynchronously();
 978             }
 979         });
 980     }
 981 
 982     /**
 983      * Constructs a new component. Class <code>Component</code> can be
 984      * extended directly to create a lightweight component that does not
 985      * utilize an opaque native window. A lightweight component must be
 986      * hosted by a native container somewhere higher up in the component
 987      * tree (for example, by a <code>Frame</code> object).
 988      */
 989     protected Component() {
 990         appContext = AppContext.getAppContext();
 991     }
 992 
 993     @SuppressWarnings({"rawtypes", "unchecked"})
 994     void initializeFocusTraversalKeys() {
 995         focusTraversalKeys = new Set[3];
 996     }
 997 
 998     /**


2964         }
2965     }
2966 
2967     /**
2968      * Revalidates the component hierarchy up to the nearest validate root.
2969      * <p>
2970      * This method first invalidates the component hierarchy starting from this
2971      * component up to the nearest validate root. Afterwards, the component
2972      * hierarchy is validated starting from the nearest validate root.
2973      * <p>
2974      * This is a convenience method supposed to help application developers
2975      * avoid looking for validate roots manually. Basically, it's equivalent to
2976      * first calling the {@link #invalidate()} method on this component, and
2977      * then calling the {@link #validate()} method on the nearest validate
2978      * root.
2979      *
2980      * @see Container#isValidateRoot
2981      * @since 1.7
2982      */
2983     public void revalidate() {
2984         revalidateSynchronously();
2985     }
2986 
2987     /**
2988      * Revalidates the component synchronously.
2989      */
2990     final void revalidateSynchronously() {
2991         synchronized (getTreeLock()) {
2992             invalidate();
2993 
2994             Container root = getContainer();
2995             if (root == null) {
2996                 // There's no parents. Just validate itself.
2997                 validate();
2998             } else {
2999                 while (!root.isValidateRoot()) {
3000                     if (root.getContainer() == null) {
3001                         // If there's no validate roots, we'll validate the
3002                         // topmost container
3003                         break;
3004                     }
3005 
3006                     root = root.getContainer();
3007                 }
3008 
3009                 root.validate();
3010             }