Class LookUtils


  • public final class LookUtils
    extends com.jgoodies.common.base.SystemUtils
    Provides convenience behavior used by the JGoodies Looks.
    Version:
    $Revision: 1.18 $
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean IS_OS_WINDOWS_95
      True if this is Windows 95.
      static boolean IS_OS_WINDOWS_MODERN
      True if this is Windows 98/ME/2000/Server 2003/XP/VISTA/Server 2008.
      static boolean IS_OS_WINDOWS_NT
      True if this is Windows NT.
      private static boolean loggingEnabled  
      • Fields inherited from class com.jgoodies.common.base.SystemUtils

        HAS_MODERN_RASTERIZER, IS_JAVA_6, IS_JAVA_7, IS_JAVA_7_OR_LATER, IS_JAVA_8, IS_JAVA_8_OR_LATER, IS_LAF_WINDOWS_XP_ENABLED, IS_LOW_RESOLUTION, IS_OS_LINUX, IS_OS_MAC, IS_OS_SOLARIS, IS_OS_WINDOWS, IS_OS_WINDOWS_2000, IS_OS_WINDOWS_6_OR_LATER, IS_OS_WINDOWS_7, IS_OS_WINDOWS_8, IS_OS_WINDOWS_98, IS_OS_WINDOWS_ME, IS_OS_WINDOWS_VISTA, IS_OS_WINDOWS_XP, IS_OS_WINDOWS_XP_64_BIT_OR_SERVER_2003, JAVA_VERSION, OS_NAME, OS_VERSION
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private LookUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Boolean getBooleanSystemProperty​(java.lang.String key, java.lang.String logMessage)
      Checks if a boolean system property has been set for the given key, and returns the associated Boolean, or null if no value has been set.
      static java.lang.Object getDefaultTheme​(javax.swing.LookAndFeel laf)  
      static java.util.List getInstalledThemes​(javax.swing.LookAndFeel laf)  
      static java.awt.Color getSlightlyBrighter​(java.awt.Color color)
      Computes and returns a Color that is slightly brighter than the specified Color.
      static java.awt.Color getSlightlyBrighter​(java.awt.Color color, float factor)
      Computes and returns a Color that is slightly brighter than the specified Color.
      static java.lang.String getSystemProperty​(java.lang.String key)
      Tries to look up the System property for the given key.
      static java.lang.String getSystemProperty​(java.lang.String key, java.lang.String defaultValue)
      Tries to look up the System property for the given key.
      static boolean getToolkitUsesNativeDropShadows()
      Checks and answers whether this toolkit provides native drop shadows for popups such as the Mac OS X.
      static boolean isTrueColor​(java.awt.Component c)
      Checks and answers whether we have a true color system.
      static void log()
      Prints a new line to the console if logging is enabled.
      static void log​(java.lang.String message)
      Prints the given message to the console if logging is enabled.
      static void setLoggingEnabled​(boolean enabled)
      Enables or disables the Looks logging.
      static void setLookAndTheme​(javax.swing.LookAndFeel laf, java.lang.Object theme)  
      • Methods inherited from class com.jgoodies.common.base.SystemUtils

        isLafAqua, startsWith
      • Methods inherited from class java.lang.Object

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

      • IS_OS_WINDOWS_MODERN

        public static final boolean IS_OS_WINDOWS_MODERN
        True if this is Windows 98/ME/2000/Server 2003/XP/VISTA/Server 2008.
      • IS_OS_WINDOWS_95

        public static final boolean IS_OS_WINDOWS_95
        True if this is Windows 95.
        Since:
        2.0
      • IS_OS_WINDOWS_NT

        public static final boolean IS_OS_WINDOWS_NT
        True if this is Windows NT.
        Since:
        2.0
      • loggingEnabled

        private static boolean loggingEnabled
    • Constructor Detail

      • LookUtils

        private LookUtils()
    • Method Detail

      • getSystemProperty

        public static java.lang.String getSystemProperty​(java.lang.String key)
        Tries to look up the System property for the given key. In untrusted environments this may throw a SecurityException. In this case we catch the exception and answer null.
        Parameters:
        key - the name of the system property
        Returns:
        the system property's String value, or null if there's no such value, or a SecurityException has been caught
      • getSystemProperty

        public static java.lang.String getSystemProperty​(java.lang.String key,
                                                         java.lang.String defaultValue)
        Tries to look up the System property for the given key. In untrusted environments this may throw a SecurityException. In this case, we catch the exception and answer the default value.
        Parameters:
        key - the name of the system property
        defaultValue - the default value if no property exists.
        Returns:
        the system property's String value, or the defaultValue if there's no such value, or a SecurityException has been caught
      • getBooleanSystemProperty

        public static java.lang.Boolean getBooleanSystemProperty​(java.lang.String key,
                                                                 java.lang.String logMessage)
        Checks if a boolean system property has been set for the given key, and returns the associated Boolean, or null if no value has been set. The test for the property ignores case. If a Boolean value has been set, a message is logged with the given prefix.
        Parameters:
        key - the key used to lookup the system property value
        logMessage - a prefix used when a message is logged
        Returns:
        Boolean.TRUE if the system property has been set to "true" (case ignored), Boolean.FALSE if it has been set to "false", null otherwise
      • isTrueColor

        public static boolean isTrueColor​(java.awt.Component c)
        Checks and answers whether we have a true color system.
        Parameters:
        c - the component used to determine the toolkit
        Returns:
        true if the component's toolkit has a pixel size >= 24
      • getToolkitUsesNativeDropShadows

        public static boolean getToolkitUsesNativeDropShadows()
        Checks and answers whether this toolkit provides native drop shadows for popups such as the Mac OS X. Currently this is used to determine if the Looks' popup drop shadow feature is active or not - even if it's enabled.
        Returns:
        true if the toolkit provides native drop shadows
        See Also:
        Options.isPopupDropShadowActive()
      • getSlightlyBrighter

        public static java.awt.Color getSlightlyBrighter​(java.awt.Color color)
        Computes and returns a Color that is slightly brighter than the specified Color.
        Parameters:
        color - the color used as basis for the brightened color
        Returns:
        a slightly brighter color
      • getSlightlyBrighter

        public static java.awt.Color getSlightlyBrighter​(java.awt.Color color,
                                                         float factor)
        Computes and returns a Color that is slightly brighter than the specified Color.
        Parameters:
        color - the color used as basis for the brightened color
        factor - the factor used to compute the brightness
        Returns:
        a slightly brighter color
      • setLookAndTheme

        public static void setLookAndTheme​(javax.swing.LookAndFeel laf,
                                           java.lang.Object theme)
                                    throws javax.swing.UnsupportedLookAndFeelException
        Throws:
        javax.swing.UnsupportedLookAndFeelException
      • getDefaultTheme

        public static java.lang.Object getDefaultTheme​(javax.swing.LookAndFeel laf)
      • getInstalledThemes

        public static java.util.List getInstalledThemes​(javax.swing.LookAndFeel laf)
      • setLoggingEnabled

        public static void setLoggingEnabled​(boolean enabled)
        Enables or disables the Looks logging.
        Parameters:
        enabled - true to enable logging, false to disable it
      • log

        public static void log()
        Prints a new line to the console if logging is enabled.
      • log

        public static void log​(java.lang.String message)
        Prints the given message to the console if logging is enabled.
        Parameters:
        message - the message to print