edu.neu.ccs.gui
Class LookAndFeelTools

java.lang.Object
  extended byedu.neu.ccs.gui.LookAndFeelTools
All Implemented Interfaces:
JPTConstants, SwingConstants

public class LookAndFeelTools
extends Object
implements JPTConstants

Class LookAndFeelTools contains several static methods that assist in using the Java look and feel facilities.

Class LookAndFeelTools cannot be instantiated.

In 2.6.0, we needed to supply a workaround to a bug in Java 6. If you are interested, look up the source and see the comments in the method adjustAllDefaultFontSizes.

Since:
2.3
Version:
2.6.0

Field Summary
private static int MAX_ADJUSTMENT
          The maximum font size adjustment shown in the look and feel dialog.
static float MINIMUM_NET_FONT_SIZE_ADJUSTMENT
          The lower bound for the net font size adjustment.
private static float netFontSizeAdjustment
          The net font size adjustment made after one or more calls of these tools.
 
Fields inherited from interface edu.neu.ccs.util.JPTConstants
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
private LookAndFeelTools()
          Private constructor to prevent instantiation.
 
Method Summary
static void adjustAllDefaultFontSizes(float delta)
          Adjusts the font size of all default fonts by adding the given delta to the current font size of each font.
static String[] getInstalledLookAndFeelClassNames()
          Returns the array of class names of the installed look and feel entities.
static String[] getInstalledLookAndFeelNames()
          Returns the array of short names of the installed look and feel entities.
static float getNetFontSizeAdjustment()
          Returns the net font size adjustment to the look and feel fonts after one or more calls to the tools in this package.
static void setNetFontSizeAdjustment(float delta)
          Sets the net font size adjustment to the look and feel fonts to the given delta.
static void showSelectLookAndFeelDialog()
          Displays a dialog that permits the user to select the look and feel from among the look and feel options that are currently installed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_ADJUSTMENT

private static final int MAX_ADJUSTMENT
The maximum font size adjustment shown in the look and feel dialog.

See Also:
Constant Field Values

netFontSizeAdjustment

private static float netFontSizeAdjustment
The net font size adjustment made after one or more calls of these tools.


MINIMUM_NET_FONT_SIZE_ADJUSTMENT

public static final float MINIMUM_NET_FONT_SIZE_ADJUSTMENT
The lower bound for the net font size adjustment. This lower bound prevents the font sizes from being set to very small or negative values.

See Also:
Constant Field Values
Constructor Detail

LookAndFeelTools

private LookAndFeelTools()
Private constructor to prevent instantiation.

Method Detail

showSelectLookAndFeelDialog

public static void showSelectLookAndFeelDialog()

Displays a dialog that permits the user to select the look and feel from among the look and feel options that are currently installed.

In addition, permits the user to adjust the font size of each default font by a fixed amount specified by a sequence of constants provided in the dialog.

This method must be called before any GUI objects are displayed on screen. Therefore, it is best to make the following code the first line of the main method that launches the program:


getInstalledLookAndFeelNames

public static String[] getInstalledLookAndFeelNames()
Returns the array of short names of the installed look and feel entities.


getInstalledLookAndFeelClassNames

public static String[] getInstalledLookAndFeelClassNames()
Returns the array of class names of the installed look and feel entities.


adjustAllDefaultFontSizes

public static void adjustAllDefaultFontSizes(float delta)

Adjusts the font size of all default fonts by adding the given delta to the current font size of each font.

The method recognizes a default font by looking for the String "font" in each key of a UIDefaults object.

This method prevents the net font size adjustment obtained from one or more calls to the tools in this package from becoming less than the lower bound MINIMUM_NET_FONT_SIZE_ADJUSTMENT.

Parameters:
delta - the incremental change in font sizes

setNetFontSizeAdjustment

public static void setNetFontSizeAdjustment(float delta)

Sets the net font size adjustment to the look and feel fonts to the given delta.

Parameters:
delta - the absolute change in font sizes

getNetFontSizeAdjustment

public static float getNetFontSizeAdjustment()

Returns the net font size adjustment to the look and feel fonts after one or more calls to the tools in this package.