edu.northwestern.at.utils.swing
Class LookAndFeel

java.lang.Object
  extended by edu.northwestern.at.utils.swing.LookAndFeel

public class LookAndFeel
extends java.lang.Object

Swing Look and Feel.

Swing allows changing the "skin" or "look and feel" of windows on the fly. The methods here support a variety of built-in and third-party skins.


Nested Class Summary
static class LookAndFeel.ExtendedLookAndFeelInfo
           
 
Field Summary
protected static java.lang.String lookAndFeelDirectory
           
static LookAndFeel.ExtendedLookAndFeelInfo[] lookAndFeels
           
 
Constructor Summary
LookAndFeel()
           
 
Method Summary
static void changefontSizes(int fontDelta)
          Changes the current font size for all user interface objects.
static void enableAntialiasedFontRendering()
          Enable antialiased font rendering in Java 5 or later.
static java.lang.String getActiveLookAndFeel()
          Get the class name of the currently active look and feel.
static java.lang.Class getActiveLookAndFeelClass()
          Get the class of the currently active look and feel.
static LookAndFeel.ExtendedLookAndFeelInfo[] getExtendedLookAndFeelInfo()
          Get list of available look and feels.
static boolean isMetal()
          Check if Metal look and feel is the current look and feel.
static boolean isNativeLookAndFeel()
          Checks if current Look and Feel is system default.
static boolean setLookAndFeel(java.lang.String lookAndFeelName)
          Sets a new Swing look and feel.
static boolean setLookAndFeelByClassName(java.lang.String lookAndFeelClassName)
          Sets a new Swing look and feel by class name.
static boolean setLookAndFeelByClassName(java.lang.String lookAndFeelClassName, boolean updateWindows)
          Sets a new Swing look and feel by class name.
static void setNativeLookAndFeel()
          Sets Swing look and feel to native look and feel.
static void setNiceLookAndFeel()
          Sets Swing look and feel to a "nice" look and feel.
static void updateLookAndFeel()
          Updates look and feel of all existing windows to new look and feel.
static void updateLookAndFeelOfChildWindows(java.awt.Window window)
          Updates look and feel of child windows to new current look and feel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lookAndFeelDirectory

protected static java.lang.String lookAndFeelDirectory

lookAndFeels

public static LookAndFeel.ExtendedLookAndFeelInfo[] lookAndFeels
Constructor Detail

LookAndFeel

public LookAndFeel()
Method Detail

getActiveLookAndFeelClass

public static java.lang.Class getActiveLookAndFeelClass()
Get the class of the currently active look and feel.

Returns:
The class of the currently active look and feel.

getActiveLookAndFeel

public static java.lang.String getActiveLookAndFeel()
Get the class name of the currently active look and feel.

Returns:
The class name of the currently active look and feel.

getExtendedLookAndFeelInfo

public static LookAndFeel.ExtendedLookAndFeelInfo[] getExtendedLookAndFeelInfo()
Get list of available look and feels.

The complete list of possible look and feels is pruned to those for which the implementing class actually exists.


isMetal

public static boolean isMetal()
Check if Metal look and feel is the current look and feel.

Returns:
true if Metal is the current look and feel.

setLookAndFeel

public static boolean setLookAndFeel(java.lang.String lookAndFeelName)
Sets a new Swing look and feel.

Parameters:
lookAndFeelName - The name of the new look and feel. This is converted to appropriate class name and/or file name references to load the selected look and feel. If the selected look and feel is not available, the default system look and feel is used instead.
Returns:
true if selected look and feel set.

Reflection is used to invoke the alternative look and feel classes so no errors will occur if the libraries implementing the new interfaces are missing from the client system. Some interfaces (e.g., "windows") only work on certain systems because of licensing issues.


setNativeLookAndFeel

public static void setNativeLookAndFeel()
Sets Swing look and feel to native look and feel.


setNiceLookAndFeel

public static void setNiceLookAndFeel()
Sets Swing look and feel to a "nice" look and feel.

We start by checking if the current look and feel is the native look and feel. If not, we leave it alone and do nothing here.

For Windows, a custom look and feel is used which adds font smoothing to the standard native look and feel.

For Mac OS X, the standard native look and feel is always used.

For other systems, we get the currently defined look and feel and see if it is the native look and feel. If so, we substitute the JGoodies Plastic 3D look and feel instead.


isNativeLookAndFeel

public static boolean isNativeLookAndFeel()
Checks if current Look and Feel is system default.


setLookAndFeelByClassName

public static boolean setLookAndFeelByClassName(java.lang.String lookAndFeelClassName,
                                                boolean updateWindows)
Sets a new Swing look and feel by class name.

Parameters:
lookAndFeelClassName - The class name of the new look and feel.
updateWindows - True to update all existing windows to new look and feel.
Returns:
True if selected look and feel set.

setLookAndFeelByClassName

public static boolean setLookAndFeelByClassName(java.lang.String lookAndFeelClassName)
Sets a new Swing look and feel by class name.

Parameters:
lookAndFeelClassName - Class name of new look and feel.
Returns:
True if selected look and feel set.

updateLookAndFeel

public static void updateLookAndFeel()
Updates look and feel of all existing windows to new look and feel.


updateLookAndFeelOfChildWindows

public static void updateLookAndFeelOfChildWindows(java.awt.Window window)
Updates look and feel of child windows to new current look and feel.

Parameters:
window - The parent window whose children should be updated to the new current look and feel.

changefontSizes

public static void changefontSizes(int fontDelta)
Changes the current font size for all user interface objects.

Parameters:
fontDelta - The number of points by which to increase or decrease all font sizes for user interface objects.

enableAntialiasedFontRendering

public static void enableAntialiasedFontRendering()
Enable antialiased font rendering in Java 5 or later.