Class WidgetUtilities


  • public class WidgetUtilities
    extends java.lang.Object
    Various utility functions.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String PREVIEW_MODE
      Name for the internal client property that marks a component as previewable.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private WidgetUtilities()
      Private constructor.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void firePropertyChangeEvent​(javax.swing.JComponent component, java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
      Fires the matching property change event on the specific component.
      static java.awt.Composite getAlphaComposite​(java.awt.Component c)
      Returns the composite to use for painting the specified component.
      static java.awt.Composite getAlphaComposite​(java.awt.Component c, float translucency)  
      static java.awt.Composite getAlphaComposite​(java.awt.Component c, float translucency, java.awt.Graphics g)
      Returns the composite to use for painting the specified component.
      static java.awt.Composite getAlphaComposite​(java.awt.Component c, java.awt.Graphics g)
      Returns the composite to use for painting the specified component.
      static PreviewPainter getComponentPreviewPainter​(java.awt.Component comp)
      Returns the preview painter for the specified component.
      static javax.swing.Icon getIcon​(javax.swing.AbstractButton b)
      Returns the current icon for the specified button.
      static PasswordStrengthChecker getPasswordStrengthChecker​(javax.swing.JPasswordField jpf)
      Returns the password strength checker for the specified password field.
      static boolean hasAutomaticDnDSupport​(javax.swing.JTree tree)
      Checks whether the specified tree component has automatic drag and drop support.
      static boolean hasAutoScroll​(javax.swing.JScrollPane scrollPane)
      Checks whether the specified scroll pane supports auto scroll.
      static boolean hasNoAnimations​(java.awt.Component comp, RadianceThemingSlices.AnimationFacet animationFacet)
      Checks whether the specified component has been configured (specifically or globally) to have no animations of the specific facet.
      static boolean hasTextEditContextMenu​(javax.swing.text.JTextComponent textComp)
      Checks whether the specified text component has edit context menu property.
      static boolean hasTextFlipSelectOnEscapeProperty​(javax.swing.text.JTextComponent textComp)
      Checks whether the specified text component has "flip select on escape" property.
      static boolean hasTextFocusSelectAllProperty​(javax.swing.text.JTextComponent textComp)
      Checks whether the specified text component has "select all on focus gain" property.
      static void makePreviewable​(java.awt.Component comp, java.util.Map<java.awt.Component,​java.lang.Boolean> dbSnapshot)
      Makes the specified component and all its descendants previewable.
      static void restorePreviewable​(java.awt.Component comp, java.util.Map<java.awt.Component,​java.lang.Boolean> dbSnapshot)
      Restores the regular (non-previewable) status of the specified component and all its descendants.
      static boolean toIgnoreAnimations​(java.awt.Component comp)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PREVIEW_MODE

        public static final java.lang.String PREVIEW_MODE
        Name for the internal client property that marks a component as previewable.
        See Also:
        Constant Field Values
    • Constructor Detail

      • WidgetUtilities

        private WidgetUtilities()
        Private constructor. Is here to enforce using static methods only.
    • Method Detail

      • makePreviewable

        public static void makePreviewable​(java.awt.Component comp,
                                           java.util.Map<java.awt.Component,​java.lang.Boolean> dbSnapshot)
        Makes the specified component and all its descendants previewable.
        Parameters:
        comp - Component.
        dbSnapshot - The "snapshot" map that will contain the original double-buffer status of the specified component and all its descendants. Key is JComponent, value is Boolean.
      • restorePreviewable

        public static void restorePreviewable​(java.awt.Component comp,
                                              java.util.Map<java.awt.Component,​java.lang.Boolean> dbSnapshot)
        Restores the regular (non-previewable) status of the specified component and all its descendants.
        Parameters:
        comp - Component.
        dbSnapshot - The "snapshot" map that contains the original double-buffer status of the specified component and all its descendants. Key is JComponent, value is Boolean.
      • hasTextFocusSelectAllProperty

        public static boolean hasTextFocusSelectAllProperty​(javax.swing.text.JTextComponent textComp)
        Checks whether the specified text component has "select all on focus gain" property.
        Parameters:
        textComp - Text component.
        Returns:
        true if the specified text component has "select all on focus gain" property, false otherwise.
      • hasTextFlipSelectOnEscapeProperty

        public static boolean hasTextFlipSelectOnEscapeProperty​(javax.swing.text.JTextComponent textComp)
        Checks whether the specified text component has "flip select on escape" property.
        Parameters:
        textComp - Text component.
        Returns:
        true if the specified text component has "flip select on escape" property, false otherwise.
      • hasTextEditContextMenu

        public static boolean hasTextEditContextMenu​(javax.swing.text.JTextComponent textComp)
        Checks whether the specified text component has edit context menu property.
        Parameters:
        textComp - Text component.
        Returns:
        true if the specified text component has edit context menu property, false otherwise.
      • hasAutoScroll

        public static boolean hasAutoScroll​(javax.swing.JScrollPane scrollPane)
        Checks whether the specified scroll pane supports auto scroll.
        Parameters:
        scrollPane - Scroll pane component.
        Returns:
        true if the specified scroll pane supports auto scroll, false otherwise.
      • hasAutomaticDnDSupport

        public static boolean hasAutomaticDnDSupport​(javax.swing.JTree tree)
        Checks whether the specified tree component has automatic drag and drop support.
        Parameters:
        tree - Tree component.
        Returns:
        true if the specified text component has automatic drag and drop support, false otherwise.
      • hasNoAnimations

        public static boolean hasNoAnimations​(java.awt.Component comp,
                                              RadianceThemingSlices.AnimationFacet animationFacet)
        Checks whether the specified component has been configured (specifically or globally) to have no animations of the specific facet. Can be used to cull unnecessary code in animation listeners on large tables and lists.
        Parameters:
        comp - Component.
        animationFacet - Animation facet.
        Returns:
        true if the specified component has been configured (specifically or globally) to have no animations of the specific facet, false otherwise.
      • getIcon

        public static javax.swing.Icon getIcon​(javax.swing.AbstractButton b)
        Returns the current icon for the specified button. This method is for internal use only.
        Parameters:
        b - Button.
        Returns:
        Icon for the specified button.
      • toIgnoreAnimations

        public static boolean toIgnoreAnimations​(java.awt.Component comp)
      • firePropertyChangeEvent

        public static void firePropertyChangeEvent​(javax.swing.JComponent component,
                                                   java.lang.String propertyName,
                                                   java.lang.Object oldValue,
                                                   java.lang.Object newValue)
        Fires the matching property change event on the specific component.
        Parameters:
        component - Component.
        propertyName - Property name.
        oldValue - Old property value.
        newValue - New property value.
      • getAlphaComposite

        public static java.awt.Composite getAlphaComposite​(java.awt.Component c,
                                                           float translucency,
                                                           java.awt.Graphics g)
        Returns the composite to use for painting the specified component. The result should be set on the Graphics2D before any custom rendering is done. This method can be used by application painting code and by look-and-feel delegates.
        Parameters:
        c - Component.
        translucency - The translucency of the original painting.
        g - The original graphics context.
        Returns:
        The composite to use for painting the specified component.
      • getAlphaComposite

        public static java.awt.Composite getAlphaComposite​(java.awt.Component c,
                                                           float translucency)
      • getAlphaComposite

        public static java.awt.Composite getAlphaComposite​(java.awt.Component c,
                                                           java.awt.Graphics g)
        Returns the composite to use for painting the specified component. The result should be set on the Graphics2D before any custom rendering is done. This method can be used by application painting code and by look-and-feel delegates.
        Parameters:
        c - Component.
        Returns:
        The composite to use for painting the specified component.
      • getAlphaComposite

        public static java.awt.Composite getAlphaComposite​(java.awt.Component c)
        Returns the composite to use for painting the specified component. The result should be set on the Graphics2D before any custom rendering is done. This method can be used by application painting code and by look-and-feel delegates.
        Parameters:
        c - Component.
        Returns:
        The composite to use for painting the specified component.
      • getComponentPreviewPainter

        public static PreviewPainter getComponentPreviewPainter​(java.awt.Component comp)
        Returns the preview painter for the specified component.
        Parameters:
        comp - Component.
        Returns:
        Preview painter for the specified component.
      • getPasswordStrengthChecker

        public static PasswordStrengthChecker getPasswordStrengthChecker​(javax.swing.JPasswordField jpf)
        Returns the password strength checker for the specified password field.
        Parameters:
        jpf - Password field.
        Returns:
        Password strength checker for the specified password field. The result can be null.