Class DisabledPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class DisabledPanel extends JPanel
See Also:
  • Constructor Details

    • DisabledPanel

      public DisabledPanel(Container container)
      Create a DisablePanel for the specified Container. The disabled color will be the following color from the UIManager with an alpha value: UIManager.getColor("inactiveCaptionBorder");
      Parameters:
      container - a Container to be added to this DisabledPanel
    • DisabledPanel

      public DisabledPanel(Container container, Color disabledColor)
      Create a DisablePanel for the specified Container using the specified disabled color.
      Parameters:
      container - a Container to be added to this DisabledPanel
      disabledColor - the background color of the GlassPane
  • Method Details

    • getDisabledColor

      public Color getDisabledColor()
      The background color of the glass pane.
      Returns:
      the background color of the glass pane
    • setDisabledColor

      public void setDisabledColor(Color disabledColor)
      Set the background color of the glass pane. This color should contain an alpha value to give the glass pane a transparent effect.
      Parameters:
      disabledColor - the background color of the glass pane
    • getGlassPane

      public JComponent getGlassPane()
      The glass pane of this DisablePanel. It can be customized by adding components to it.
      Returns:
      the glass pane
    • setGlassPane

      public void setGlassPane(JComponent glassPane)
      Use a custom glass pane. You are responsible for adding the appropriate mouse listeners to intercept mouse events.
      Parameters:
      glassPane - a JComponent to be used as a glass pane
    • setEnabled

      public void setEnabled(boolean enabled)
      Change the enabled state of the panel.
      Overrides:
      setEnabled in class JComponent
    • isOptimizedDrawingEnabled

      public boolean isOptimizedDrawingEnabled()
      Because we use layered panels this should be disabled.
      Overrides:
      isOptimizedDrawingEnabled in class JComponent
    • disable

      public static void disable(Container container)
      Convenience static method to disable all components of a given Container, including nested Containers.
      Parameters:
      container - the Container containing Components to be disabled
    • enable

      public static void enable(Container container)
      Convenience static method to enable Components disabled by using the disable() method. Only Components disable by the disable() method will be enabled.
      Parameters:
      container - a Container that has been previously disabled.
    • getDescendantsOfType

      public static <T extends JComponent> List<T> getDescendantsOfType(Class<T> clazz, Container container)
      Convenience method for searching below container in the component hierarchy and return nested components that are instances of class clazz it finds. Returns an empty list if no such components exist in the container.

      Invoking this method with a class parameter of JComponent.class will return all nested components.

      This method invokes getDescendantsOfType(clazz, container, true)

      Type Parameters:
      T - type
      Parameters:
      clazz - the class of components whose instances are to be found.
      container - the container at which to begin the search
      Returns:
      the List of components
    • getDescendantsOfType

      public static <T extends JComponent> List<T> getDescendantsOfType(Class<T> clazz, Container container, boolean nested)
      Convenience method for searching below container in the component hierarchy and return nested components that are instances of class clazz it finds. Returns an empty list if no such components exist in the container.

      Invoking this method with a class parameter of JComponent.class will return all nested components.

      Type Parameters:
      T - type
      Parameters:
      clazz - the class of components whose instances are to be found.
      container - the container at which to begin the search
      nested - true to list components nested within another listed component, false otherwise
      Returns:
      the List of components
    • getDescendantOfType

      public static <T extends JComponent> T getDescendantOfType(Class<T> clazz, Container container, String property, Object value) throws IllegalArgumentException
      Convenience method that searches below container in the component hierarchy and returns the first found component that is an instance of class clazz having the bound property value. Returns null if such component cannot be found.

      This method invokes getDescendantOfType(clazz, container, property, value, true)

      Type Parameters:
      T - type
      Parameters:
      clazz - the class of component whose instance is to be found.
      container - the container at which to begin the search
      property - the className of the bound property, exactly as expressed in the accessor e.g. "Text" for getText(), "Value" for getValue().
      value - the value of the bound property
      Returns:
      the component, or null if no such component exists in the container
      Throws:
      IllegalArgumentException - if the bound property does not exist for the class or cannot be accessed
    • getDescendantOfType

      public static <T extends JComponent> T getDescendantOfType(Class<T> clazz, Container container, String property, Object value, boolean nested) throws IllegalArgumentException
      Convenience method that searches below container in the component hierarchy and returns the first found component that is an instance of class clazz and has the bound property value. Returns null if such component cannot be found.
      Type Parameters:
      T - type
      Parameters:
      clazz - the class of component whose instance to be found.
      container - the container at which to begin the search
      property - the className of the bound property, exactly as expressed in the accessor e.g. "Text" for getText(), "Value" for getValue().
      value - the value of the bound property
      nested - true to list components nested within another component which is also an instance of clazz, false otherwise
      Returns:
      the component, or null if no such component exists in the container
      Throws:
      IllegalArgumentException - if the bound property does not exist for the class or cannot be accessed
    • getDescendantsOfClass

      public static <T extends JComponent> List<T> getDescendantsOfClass(Class<T> clazz, Container container)
      Convenience method for searching below container in the component hierarchy and return nested components of class clazz it finds. Returns an empty list if no such components exist in the container.

      This method invokes getDescendantsOfClass(clazz, container, true)

      Type Parameters:
      T - type
      Parameters:
      clazz - the class of components to be found.
      container - the container at which to begin the search
      Returns:
      the List of components
    • getDescendantsOfClass

      public static <T extends JComponent> List<T> getDescendantsOfClass(Class<T> clazz, Container container, boolean nested)
      Convenience method for searching below container in the component hierarchy and return nested components of class clazz it finds. Returns an empty list if no such components exist in the container.
      Type Parameters:
      T - type
      Parameters:
      clazz - the class of components to be found.
      container - the container at which to begin the search
      nested - true to list components nested within another listed component, false otherwise
      Returns:
      the List of components
    • getDescendantOfClass

      public static <T extends JComponent> T getDescendantOfClass(Class<T> clazz, Container container, String property, Object value) throws IllegalArgumentException
      Convenience method that searches below container in the component hierarchy in a depth first manner and returns the first found component of class clazz having the bound property value.

      Returns null if such component cannot be found.

      This method invokes getDescendantOfClass(clazz, container, property, value, true)

      Type Parameters:
      T - type
      Parameters:
      clazz - the class of component to be found.
      container - the container at which to begin the search
      property - the className of the bound property, exactly as expressed in the accessor e.g. "Text" for getText(), "Value" for getValue(). This parameter is case sensitive.
      value - the value of the bound property
      Returns:
      the component, or null if no such component exists in the container's hierarchy.
      Throws:
      IllegalArgumentException - if the bound property does not exist for the class or cannot be accessed
    • getDescendantOfClass

      public static <T extends JComponent> T getDescendantOfClass(Class<T> clazz, Container container, String property, Object value, boolean nested) throws IllegalArgumentException
      Convenience method that searches below container in the component hierarchy in a depth first manner and returns the first found component of class clazz having the bound property value.

      Returns null if such component cannot be found.

      Type Parameters:
      T - type
      Parameters:
      clazz - the class of component to be found.
      container - the container at which to begin the search
      property - the className of the bound property, exactly as expressed in the accessor e.g. "Text" for getText(), "Value" for getValue(). This parameter is case sensitive.
      value - the value of the bound property
      nested - true to include components nested within another listed component, false otherwise
      Returns:
      the component, or null if no such component exists in the container's hierarchy
      Throws:
      IllegalArgumentException - if the bound property does not exist for the class or cannot be accessed
    • equals

      public static boolean equals(Object obj1, Object obj2)
      Convenience method for determining whether two objects are either equal or both null.
      Parameters:
      obj1 - the first reference object to compare.
      obj2 - the second reference object to compare.
      Returns:
      true if obj1 and obj2 are equal or if both are null, false otherwise
    • getComponentMap

      public static Map<JComponent, List<JComponent>> getComponentMap(JComponent container, boolean nested)
      Convenience method for mapping a container in the hierarchy to its contained components. The keys are the containers, and the values are lists of contained components.

      Implementation note: The returned value is a HashMap and the values are of type ArrayList. This is subject to change, so callers should code against the interfaces Map and List.

      Parameters:
      container - The JComponent to be mapped
      nested - true to drill down to nested containers, false otherwise
      Returns:
      the Map of the UI
    • getUIDefaultsOfClass

      public static UIDefaults getUIDefaultsOfClass(Class clazz)
      Convenience method for retrieving a subset of the UIDefaults pertaining to a particular class.
      Parameters:
      clazz - the class of interest
      Returns:
      the UIDefaults of the class
    • getUIDefaultsOfClass

      public static UIDefaults getUIDefaultsOfClass(String className)
      Convenience method for retrieving a subset of the UIDefaults pertaining to a particular class.
      Parameters:
      className - fully qualified name of the class of interest
      Returns:
      the UIDefaults of the class named
    • getUIDefaultOfClass

      public static Object getUIDefaultOfClass(Class clazz, String property)
      Convenience method for retrieving the UIDefault for a single property of a particular class.
      Parameters:
      clazz - the class of interest
      property - the property to query
      Returns:
      the UIDefault property, or null if not found
    • getProperties

      public static Map<Object,Object> getProperties(JComponent component)
      Convenience method for obtaining most non-null human readable properties of a JComponent. Array properties are not included.

      Implementation note: The returned value is a HashMap. This is subject to change, so callers should code against the interface Map.

      Parameters:
      component - the component whose properties are to be determined
      Returns:
      the class and value of the properties
    • getJClass

      public static <T extends JComponent> Class getJClass(T component)
      Convenience method to obtain the Swing class from which this component was directly or indirectly derived.
      Type Parameters:
      T - type
      Parameters:
      component - The component whose Swing superclass is to be determined
      Returns:
      The nearest Swing class in the inheritance tree