Class UIDefaultsLookup


  • public class UIDefaultsLookup
    extends java.lang.Object
    This class simply uses UIManager's get method to lookup the UIDefaults. We used this everywhere in our code so that we have one central place to find out which UIDefaults we are using. Another good thing is you can use setTrace(boolean) and setDebug(boolean) to turn on the trace so that it will print out which UIDefaults we are trying to get.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object get​(java.lang.Object key)  
      static java.lang.Object get​(java.lang.Object key, java.util.Locale l)  
      static boolean getBoolean​(java.lang.Object key)
      If the value of key is boolean, return the boolean value, otherwise return false.
      static boolean getBoolean​(java.lang.Object key, boolean defaultValue)
      If the value of key is boolean, return the boolean value, otherwise return false.
      static boolean getBoolean​(java.lang.Object key, java.util.Locale l)
      If the value of key for the given Locale is boolean, return the boolean value, otherwise return false.
      static javax.swing.border.Border getBorder​(java.lang.Object key)
      If the value of key is a Border return it, otherwise return null.
      static javax.swing.border.Border getBorder​(java.lang.Object key, java.util.Locale l)
      If the value of key for the given Locale is a Border return it, otherwise return null.
      static java.awt.Color getColor​(java.lang.Object key)
      If the value of key is a Color return it, otherwise return null.
      static java.awt.Color getColor​(java.lang.Object key, java.util.Locale l)
      If the value of key for the given Locale is a Color return it, otherwise return null.
      static java.awt.Dimension getDimension​(java.lang.Object key)
      If the value of key is a Dimension return it, otherwise return null.
      static java.awt.Dimension getDimension​(java.lang.Object key, java.util.Locale l)
      If the value of key for the given Locale is a Dimension return it, otherwise return null.
      static java.awt.Font getFont​(java.lang.Object key)
      If the value of key is a Font return it, otherwise return null.
      static java.awt.Font getFont​(java.lang.Object key, java.util.Locale l)
      If the value of key for the given Locale is a Font return it, otherwise return null.
      static javax.swing.Icon getIcon​(java.lang.Object key)
      If the value of key is an Icon return it, otherwise return null.
      static javax.swing.Icon getIcon​(java.lang.Object key, java.util.Locale l)
      If the value of key for the given Locale is an Icon return it, otherwise return null.
      static java.awt.Insets getInsets​(java.lang.Object key)
      If the value of key is an Insets return it, otherwise return null.
      static java.awt.Insets getInsets​(java.lang.Object key, java.util.Locale l)
      If the value of key for the given Locale is an Insets return it, otherwise return null.
      static int getInt​(java.lang.Object key)
      If the value of key is an Integer return its integer value, otherwise return 0.
      static int getInt​(java.lang.Object key, java.util.Locale l)
      If the value of key for the given Locale is an Integer return its integer value, otherwise return 0.
      static java.lang.String getString​(java.lang.Object key)
      If the value of key is a String return it, otherwise return null.
      static java.lang.String getString​(java.lang.Object key, java.util.Locale l)
      If the value of key for the given Locale is a String return it, otherwise return null.
      static void put​(javax.swing.UIDefaults table, java.lang.String key, java.lang.Object value)  
      static void setDebug​(boolean debug)
      Sets the debug mode.
      static void setTrace​(boolean trace)
      Sets the trace mode.
      • Methods inherited from class java.lang.Object

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

      • UIDefaultsLookup

        public UIDefaultsLookup()
    • Method Detail

      • setDebug

        public static void setDebug​(boolean debug)
        Sets the debug mode. If debug mode is on, we will print out any UIDefaults that the value is null.
        Parameters:
        debug - true or false.
      • setTrace

        public static void setTrace​(boolean trace)
        Sets the trace mode. If trace mode is on, we will print out any UIDefaults we are trying to get and its current value.
        Parameters:
        trace - true or false.
      • put

        public static void put​(javax.swing.UIDefaults table,
                               java.lang.String key,
                               java.lang.Object value)
      • get

        public static java.lang.Object get​(java.lang.Object key)
      • get

        public static java.lang.Object get​(java.lang.Object key,
                                           java.util.Locale l)
      • getFont

        public static java.awt.Font getFont​(java.lang.Object key)
        If the value of key is a Font return it, otherwise return null.
        Parameters:
        key - the desired key
        Returns:
        if the value for key is a Font, return the Font object; otherwise return null
      • getFont

        public static java.awt.Font getFont​(java.lang.Object key,
                                            java.util.Locale l)
        If the value of key for the given Locale is a Font return it, otherwise return null.
        Parameters:
        key - the desired key
        l - the desired locale
        Returns:
        if the value for key and Locale is a Font, return the Font object; otherwise return null
        Since:
        1.9.5.04
      • getColor

        public static java.awt.Color getColor​(java.lang.Object key)
        If the value of key is a Color return it, otherwise return null.
        Parameters:
        key - the desired key
        Returns:
        if the value for key is a Color, return the Color object; otherwise return null
      • getColor

        public static java.awt.Color getColor​(java.lang.Object key,
                                              java.util.Locale l)
        If the value of key for the given Locale is a Color return it, otherwise return null.
        Parameters:
        key - the desired key
        l - the desired locale
        Returns:
        if the value for key and Locale is a Color, return the Color object; otherwise return null
        Since:
        1.9.5.04
      • getIcon

        public static javax.swing.Icon getIcon​(java.lang.Object key)
        If the value of key is an Icon return it, otherwise return null.
        Parameters:
        key - the desired key
        Returns:
        if the value for key is an Icon, return the Icon object; otherwise return null
      • getIcon

        public static javax.swing.Icon getIcon​(java.lang.Object key,
                                               java.util.Locale l)
        If the value of key for the given Locale is an Icon return it, otherwise return null.
        Parameters:
        key - the desired key
        l - the desired locale
        Returns:
        if the value for key and Locale is an Icon, return the Icon object; otherwise return null
        Since:
        1.9.5.04
      • getBorder

        public static javax.swing.border.Border getBorder​(java.lang.Object key)
        If the value of key is a Border return it, otherwise return null.
        Parameters:
        key - the desired key
        Returns:
        if the value for key is a Border, return the Border object; otherwise return null
      • getBorder

        public static javax.swing.border.Border getBorder​(java.lang.Object key,
                                                          java.util.Locale l)
        If the value of key for the given Locale is a Border return it, otherwise return null.
        Parameters:
        key - the desired key
        l - the desired locale
        Returns:
        if the value for key and Locale is a Border, return the Border object; otherwise return null
        Since:
        1.9.5.04
      • getString

        public static java.lang.String getString​(java.lang.Object key)
        If the value of key is a String return it, otherwise return null.
        Parameters:
        key - the desired key
        Returns:
        if the value for key is a String, return the String object; otherwise return null
      • getString

        public static java.lang.String getString​(java.lang.Object key,
                                                 java.util.Locale l)
        If the value of key for the given Locale is a String return it, otherwise return null.
        Parameters:
        key - the desired key
        l - the desired Locale
        Returns:
        if the value for key for the given Locale is a String, return the String object; otherwise return null
        Since:
        1.9.5.04
      • getInt

        public static int getInt​(java.lang.Object key)
        If the value of key is an Integer return its integer value, otherwise return 0.
        Parameters:
        key - the desired key
        Returns:
        if the value for key is an Integer, return its value, otherwise return 0
      • getInt

        public static int getInt​(java.lang.Object key,
                                 java.util.Locale l)
        If the value of key for the given Locale is an Integer return its integer value, otherwise return 0.
        Parameters:
        key - the desired key
        l - the desired locale
        Returns:
        if the value for key and Locale is an Integer, return its value, otherwise return 0
        Since:
        1.9.5.04
      • getBoolean

        public static boolean getBoolean​(java.lang.Object key)
        If the value of key is boolean, return the boolean value, otherwise return false.
        Parameters:
        key - an Object specifying the key for the desired boolean value
        Returns:
        if the value of key is boolean, return the boolean value, otherwise return false.
        Since:
        1.9.5.04
      • getBoolean

        public static boolean getBoolean​(java.lang.Object key,
                                         boolean defaultValue)
        If the value of key is boolean, return the boolean value, otherwise return false.
        Parameters:
        key - an Object specifying the key for the desired boolean value
        defaultValue - the default value if the key is missing
        Returns:
        if the value of key is boolean, return the boolean value, otherwise return false.
      • getBoolean

        public static boolean getBoolean​(java.lang.Object key,
                                         java.util.Locale l)
        If the value of key for the given Locale is boolean, return the boolean value, otherwise return false.
        Parameters:
        key - an Object specifying the key for the desired boolean value
        l - the desired locale
        Returns:
        if the value for key and Locale is boolean, return the boolean value, otherwise return false.
        Since:
        1.9.5.04
      • getInsets

        public static java.awt.Insets getInsets​(java.lang.Object key)
        If the value of key is an Insets return it, otherwise return null.
        Parameters:
        key - the desired key
        Returns:
        if the value for key is an Insets, return the Insets object; otherwise return null
      • getInsets

        public static java.awt.Insets getInsets​(java.lang.Object key,
                                                java.util.Locale l)
        If the value of key for the given Locale is an Insets return it, otherwise return null.
        Parameters:
        key - the desired key
        l - the desired locale
        Returns:
        if the value for key and Locale is an Insets, return the Insets object; otherwise return null
        Since:
        1.9.5.04
      • getDimension

        public static java.awt.Dimension getDimension​(java.lang.Object key)
        If the value of key is a Dimension return it, otherwise return null.
        Parameters:
        key - the desired key
        Returns:
        if the value for key is a Dimension, return the Dimension object; otherwise return null
      • getDimension

        public static java.awt.Dimension getDimension​(java.lang.Object key,
                                                      java.util.Locale l)
        If the value of key for the given Locale is a Dimension return it, otherwise return null.
        Parameters:
        key - the desired key
        l - the desired locale
        Returns:
        if the value for key and Locale is a Dimension, return the Dimension object; otherwise return null
        Since:
        1.9.5.04