com.jgoodies.looks

Class Options


public final class Options
extends java.lang.Object

Provides access to optional features of the JGoodies L&Fs via a key to the system properties, via a key for the UIDefaults table, via a method, or all of them.

API users can use this class' constants or their values to configure the JGoodies L&amP;f. Using the constants requires the Looks library classes in the class path of the using application/applet, where using the String values doesn't require having this class in the class path.

Version:
$Revision: 1.21 $
Author:
Karsten Lentzsch

Field Summary

static String
COMBO_POPUP_PROTOTYPE_DISPLAY_VALUE_KEY
A JComboBox client property key for the combo's popup menu prototype display value.
static String
COMBO_RENDERER_IS_BORDER_REMOVABLE
A client property key for combo box renderer components.
static String
DEFAULT_ICON_SIZE_KEY
static String
DEFAULT_LOOK_NAME
The class name of the default JGoodies L&f, PlasticXP.
static String
EMBEDDED_TABS_KEY
A JTabbedPane client property key that indicates that tabs are painted with a special embedded appearance.
static String
HEADER_STYLE_KEY
A client property key for JMenuBar and JToolBar style hints.
static String
HI_RES_DISABLED_ICON_CLIENT_KEY
A client property key for components with a disabled icon such as buttons, labels, and tabbed panes.
static String
HI_RES_GRAY_FILTER_ENABLED_KEY
A UIDefaults key for enabling/disabling the new high-resolution gray filter globally.
static String
INVERT_SELECTION_CLIENT_KEY
A JTextField client property key that specifies the direction how text shall be selected on focus gain - if at all: from start to end vs.
static String
IS_ETCHED_KEY
A JScrollPane client property key for a hint that the scroll pane border should be etched.
static String
JGOODIES_WINDOWS_NAME
The class name of the JGoodies Windows L&f.
static String
NO_CONTENT_BORDER_KEY
A JTabbedPane client property key that indicates that no content border shall be painted.
static String
NO_ICONS_KEY
A JMenu client property key for a hint that the menu items in the menu have no icons.
static String
NO_MARGIN_KEY
A JPopupMenu client property key for a hint that the border shall have no extra margin.
static String
NO_REPLACEMENT
A replacement used to replace a given L&f with nothing, that indicates that it should not be used.
static String
PLASTIC3D_NAME
The class name of the JGoodies Plastic3D L&f.
static String
PLASTICXP_NAME
The class name of the JGoodies PlasticXP L&f.
static String
PLASTIC_CONTROL_FONT_KEY
A key for setting the default control font in Plastic L&fs.
static String
PLASTIC_FONT_POLICY_KEY
A key for setting a custom FontPolicy for the Plastic L&fs.
static String
PLASTIC_MENU_FONT_KEY
A key for setting the default menu font in Plastic L&fs.
static String
PLASTIC_MICRO_LAYOUT_POLICY_KEY
A UIManager key for setting a custom MicroLayoutPolicy for the Plastic L&fs.
static String
PLASTIC_NAME
The class name of the JGoodies Plastic L&f.
static String
POPUP_DROP_SHADOW_ENABLED_KEY
A UIDefaults key for the popup drop shadow enablement.
static String
SELECT_ON_FOCUS_GAIN_CLIENT_KEY
A JTextField client property key that specifies whether all text shall be selected on focus gain.
static String
SELECT_ON_FOCUS_GAIN_KEY
A UIDefaults key for the global default whether text fields shall select all text on focus gain.
static String
SET_CARET_TO_START_ON_FOCUS_LOST_CLIENT_KEY
A JTextField client property key that specifies whether the caret shall be positioned at the start on focus lost.
static String
TAB_ICONS_ENABLED_KEY
static String
TREE_LINE_STYLE_ANGLED_VALUE
A JTree client property value that indicates that lines shall be drawn.
static String
TREE_LINE_STYLE_KEY
A JTree client property key for a tree line style hint.
static String
TREE_LINE_STYLE_NONE_VALUE
A JTree client property value that indicates that lines shall be hidden.
static String
USE_NARROW_BUTTONS_KEY
static String
USE_SYSTEM_FONTS_APP_KEY
A convenience constant for the standard Swing UIDefaults key that configures the use of system fonts.
static String
USE_SYSTEM_FONTS_KEY
A convenience constant for the standard Swing system property key that configures the use of system fonts.
static String
WINDOWS_CONTROL_FONT_KEY
A key for setting the default control font in the Windows L&f.
static String
WINDOWS_FONT_POLICY_KEY
A key for setting a custom FontPolicy for the Windows L&fs.
static String
WINDOWS_MENU_FONT_KEY
A key for setting the default menu font in the Windows L&f.
static String
WINDOWS_MICRO_LAYOUT_POLICY_KEY
A UIManager key for setting a custom MicroLayoutPolicy for the Windows L&f.

Method Summary

static String
getCrossPlatformLookAndFeelClassName()
Returns the class name for a cross-platform LookAndFeel.
static Dimension
getDefaultIconSize()
Returns the default icon size that is used in menus, menu items and toolbars.
static String
getReplacementClassNameFor(String className)
Returns the class name that can be used to replace the specified LookAndFeel class name.
static Boolean
getSelectOnFocusGainEnabled(JTextComponent c)
Returns component's individual setting for the select on focus gain feature.
static String
getSystemLookAndFeelClassName()
Returns the class name for a system specific LookAndFeel.
static boolean
getUseNarrowButtons()
Checks and answers if we shall use narrow button margins of 4 pixels.
static boolean
getUseSystemFonts()
Returns whether native system fonts shall be used, true by default unless disabled in the system properties or UIManager.
static boolean
isHiResGrayFilterEnabled()
Checks and answers whether the new high-resolution gray filter is enabled or disabled.
static boolean
isPopupDropShadowActive()
Checks and answers whether popup drop shadows are active.
static boolean
isPopupDropShadowEnabled()
Checks and answers whether the optional drop shadows for PopupMenus are enabled or disabled.
static boolean
isSelectOnFocusGainActive(JTextComponent c)
Checks and answers whether the select all on focus gain feature is active for the given field.
static boolean
isSelectOnFocusGainEnabled()
Checks and answers whether the global default for text fields is to select all text on focus gain.
static boolean
isTabIconsEnabled()
Checks and answers if we shall use icons in JTabbedPanes.
static void
putLookAndFeelReplacement(String original, String replacement)
Puts a replacement name for a given LookAndFeel class name in the list of all look and feel replacements.
static void
removeLookAndFeelReplacement(String original)
Removes a replacement name for a given LookAndFeel class name from the list of all look and feel replacements.
static void
setDefaultIconSize(Dimension defaultIconSize)
Sets the default icon size.
static void
setHiResGrayFilterEnabled(boolean b)
Enables or disables the new high-resolution gray filter globally.
static void
setPopupDropShadowEnabled(boolean b)
Enables or disables drop shadows in PopupMenus.
static void
setSelectOnFocusGainEnabled(JTextField field, Boolean b)
Overrides the global default for the select all feature for the given text field.
static void
setSelectOnFocusGainEnabled(boolean b)
Enables or disables the select on focus gain feature globally.
static void
setTabIconsEnabled(boolean b)
Enables or disables the use of icons in JTabbedPanes.
static void
setUseNarrowButtons(boolean b)
Globally sets the use narrow or standard button margins.
static void
setUseSystemFonts(boolean useSystemFonts)
Sets a value in the UIManager to indicate, that a look&feel may use the native system fonts.

Field Details

COMBO_POPUP_PROTOTYPE_DISPLAY_VALUE_KEY

public static final String COMBO_POPUP_PROTOTYPE_DISPLAY_VALUE_KEY
A JComboBox client property key for the combo's popup menu prototype display value. If this key is set, the value will be used to compute the combo popup width. This optional feature is supported by the JGoodies Windows L&f as well as the JGoodies Plastic L&fs.

COMBO_RENDERER_IS_BORDER_REMOVABLE

public static final String COMBO_RENDERER_IS_BORDER_REMOVABLE
A client property key for combo box renderer components. The Boolean value indicates whether the component's border can be temporarily removed when painting the current value or not. This is useful for custom renderers used with Windows combo boxes.
Since:
2.1
See Also:
WindowsComboBoxUI.paintCurrentValue(java.awt.Graphics, java.awt.Rectangle, boolean)

DEFAULT_ICON_SIZE_KEY

public static final String DEFAULT_ICON_SIZE_KEY

DEFAULT_LOOK_NAME

public static final String DEFAULT_LOOK_NAME
The class name of the default JGoodies L&f, PlasticXP.

EMBEDDED_TABS_KEY

public static final String EMBEDDED_TABS_KEY
A JTabbedPane client property key that indicates that tabs are painted with a special embedded appearance. Supported by the JGoodies Windows L&f and the JGoodies Plastic look&feel family. As a side effect of the embedded appearance, supporting L&fs won't paint the content border.

HEADER_STYLE_KEY

public static final String HEADER_STYLE_KEY
A client property key for JMenuBar and JToolBar style hints. Available styles are: HeaderStyle.Single and HeaderStyle.Both.

HI_RES_DISABLED_ICON_CLIENT_KEY

public static final String HI_RES_DISABLED_ICON_CLIENT_KEY
A client property key for components with a disabled icon such as buttons, labels, and tabbed panes. Specifies whether the new high resolution gray filter shall be used to compute a disabled icon - if none is available.
Since:
2.1

HI_RES_GRAY_FILTER_ENABLED_KEY

public static final String HI_RES_GRAY_FILTER_ENABLED_KEY
A UIDefaults key for enabling/disabling the new high-resolution gray filter globally. This setting can be overridden per component.
Since:
2.1

INVERT_SELECTION_CLIENT_KEY

public static final String INVERT_SELECTION_CLIENT_KEY
A JTextField client property key that specifies the direction how text shall be selected on focus gain - if at all: from start to end vs. end to start. If the value is set to Boolean.TRUE, the text is selected from end to start, otherwise it is selected from start to end.

You can set the client property using:

 aTextField.putClientProperty("JGoodies.invertSelection", Boolean.TRUE);
 
Since:
2.2

IS_ETCHED_KEY

public static final String IS_ETCHED_KEY
A JScrollPane client property key for a hint that the scroll pane border should be etched.

JGOODIES_WINDOWS_NAME

public static final String JGOODIES_WINDOWS_NAME
The class name of the JGoodies Windows L&f.

NO_CONTENT_BORDER_KEY

public static final String NO_CONTENT_BORDER_KEY
A JTabbedPane client property key that indicates that no content border shall be painted. Supported by the JGoodies Windows L&f and the JGoodies Plastic look&feel family. This effect will be achieved also if the EMBEDDED property is true.

NO_ICONS_KEY

public static final String NO_ICONS_KEY
A JMenu client property key for a hint that the menu items in the menu have no icons.

NO_MARGIN_KEY

public static final String NO_MARGIN_KEY
A JPopupMenu client property key for a hint that the border shall have no extra margin. This is useful if the popup menu contains only a single component, for example a scrollpane.

NO_REPLACEMENT

public static final String NO_REPLACEMENT
A replacement used to replace a given L&f with nothing, that indicates that it should not be used. For example, by default we mark the WindowsClass L&f this way, to remove it from L&f lists that replace the Sun Windows L&f with the JGoodies Windows L&f.
Since:
2.1.3

PLASTIC3D_NAME

public static final String PLASTIC3D_NAME
The class name of the JGoodies Plastic3D L&f.

PLASTICXP_NAME

public static final String PLASTICXP_NAME
The class name of the JGoodies PlasticXP L&f.

PLASTIC_CONTROL_FONT_KEY

public static final String PLASTIC_CONTROL_FONT_KEY
A key for setting the default control font in Plastic L&fs. Used for both the system properties and the UIDefaults table.

PLASTIC_FONT_POLICY_KEY

public static final String PLASTIC_FONT_POLICY_KEY
A key for setting a custom FontPolicy for the Plastic L&fs. Used for both the system properties and the UIDefaults table.

PLASTIC_MENU_FONT_KEY

public static final String PLASTIC_MENU_FONT_KEY
A key for setting the default menu font in Plastic L&fs. Used for both the system properties and the UIDefaults table.

PLASTIC_MICRO_LAYOUT_POLICY_KEY

public static final String PLASTIC_MICRO_LAYOUT_POLICY_KEY
A UIManager key for setting a custom MicroLayoutPolicy for the Plastic L&fs.

PLASTIC_NAME

public static final String PLASTIC_NAME
The class name of the JGoodies Plastic L&f.

POPUP_DROP_SHADOW_ENABLED_KEY

public static final String POPUP_DROP_SHADOW_ENABLED_KEY
A UIDefaults key for the popup drop shadow enablement.

SELECT_ON_FOCUS_GAIN_CLIENT_KEY

public static final String SELECT_ON_FOCUS_GAIN_CLIENT_KEY
A JTextField client property key that specifies whether all text shall be selected on focus gain. Overrides the global default.

This feature can be set using setSelectOnFocusGainEnabled(JTextField,Boolean). If you want to avoid to link application code to the JGoodies Looks library, you can set the client property directly using:

 aTextField.putClientProperty("JGoodies.selectAllOnFocusGain", Boolean.TRUE);
 
Since:
2.2

SELECT_ON_FOCUS_GAIN_KEY

public static final String SELECT_ON_FOCUS_GAIN_KEY
A UIDefaults key for the global default whether text fields shall select all text on focus gain. This can be overridden per field.
Since:
2.2

SET_CARET_TO_START_ON_FOCUS_LOST_CLIENT_KEY

public static final String SET_CARET_TO_START_ON_FOCUS_LOST_CLIENT_KEY
A JTextField client property key that specifies whether the caret shall be positioned at the start on focus lost. If the value is set to Boolean.TRUE, the caret is set to position 0 on focus lost, otherwise the caret remains unchanged.

You can set the client property using:

 aTextField.putClientProperty("JGoodies.setCaretToStartOnFocusLost", Boolean.TRUE);
 
Since:
2.2

TAB_ICONS_ENABLED_KEY

public static final String TAB_ICONS_ENABLED_KEY

TREE_LINE_STYLE_ANGLED_VALUE

public static final String TREE_LINE_STYLE_ANGLED_VALUE
A JTree client property value that indicates that lines shall be drawn.

TREE_LINE_STYLE_KEY

public static final String TREE_LINE_STYLE_KEY
A JTree client property key for a tree line style hint.

TREE_LINE_STYLE_NONE_VALUE

public static final String TREE_LINE_STYLE_NONE_VALUE
A JTree client property value that indicates that lines shall be hidden.

USE_NARROW_BUTTONS_KEY

public static final String USE_NARROW_BUTTONS_KEY

USE_SYSTEM_FONTS_APP_KEY

public static final String USE_SYSTEM_FONTS_APP_KEY
A convenience constant for the standard Swing UIDefaults key that configures the use of system fonts.

USE_SYSTEM_FONTS_KEY

public static final String USE_SYSTEM_FONTS_KEY
A convenience constant for the standard Swing system property key that configures the use of system fonts.

WINDOWS_CONTROL_FONT_KEY

public static final String WINDOWS_CONTROL_FONT_KEY
A key for setting the default control font in the Windows L&f. Used for both the system properties and the UIDefaults table.

WINDOWS_FONT_POLICY_KEY

public static final String WINDOWS_FONT_POLICY_KEY
A key for setting a custom FontPolicy for the Windows L&fs. Used for both the system properties and the UIDefaults table.
See Also:
WindowsLookAndFeel.getFontPolicy(), WindowsLookAndFeel.setFontPolicy(FontPolicy)

WINDOWS_MENU_FONT_KEY

public static final String WINDOWS_MENU_FONT_KEY
A key for setting the default menu font in the Windows L&f. Used for both the system properties and the UIDefaults table.

WINDOWS_MICRO_LAYOUT_POLICY_KEY

public static final String WINDOWS_MICRO_LAYOUT_POLICY_KEY
A UIManager key for setting a custom MicroLayoutPolicy for the Windows L&f.
See Also:
WindowsLookAndFeel.getMicroLayoutPolicy(), WindowsLookAndFeel.setMicroLayoutPolicy(MicroLayout)

Method Details

getCrossPlatformLookAndFeelClassName

public static String getCrossPlatformLookAndFeelClassName()
Returns the class name for a cross-platform LookAndFeel.
Returns:
the name of a cross platform look-and-feel class

getDefaultIconSize

public static Dimension getDefaultIconSize()
Returns the default icon size that is used in menus, menu items and toolbars. Menu items that have no icon set are aligned using the default icon dimensions.
Returns:
the dimension of the default icon

getReplacementClassNameFor

public static String getReplacementClassNameFor(String className)
Returns the class name that can be used to replace the specified LookAndFeel class name.
Parameters:
className - the name of the look-and-feel class
Returns:
the name of the suggested replacement class

getSelectOnFocusGainEnabled

public static Boolean getSelectOnFocusGainEnabled(JTextComponent c)
Returns component's individual setting for the select on focus gain feature.
Parameters:
c - the component to check
Returns:
Boolean.TRUE if enabled, Boolean.FALSE if disabled, null if the global default is used
Since:
2.2

getSystemLookAndFeelClassName

public static String getSystemLookAndFeelClassName()
Returns the class name for a system specific LookAndFeel.
Returns:
the name of the system look-and-feel class

getUseNarrowButtons

public static boolean getUseNarrowButtons()
Checks and answers if we shall use narrow button margins of 4 pixels. As of the Looks version 1.4 the default value is true (narrow) for the JGoodies Windows L&F and the JGoodies Plastic L&F family. The native Windows L&F uses narrow margins too. The default can be disabled in the system properties or UIManager.

Note: Using narrow button margins can potentially cause compatibility issues, if you don't take care that command buttons with short labels (OK) get a reasonable minimum width. Therefore you can get back to wide button margins using #setUseNarrowButtons. Sun's L&F implementations use a wider button margin of 14 pixels.

Narrow button margins make it easier to give buttons in a button bar the same width, even if some button labels are long. And narrow margins are useful for embedded command buttons that just have an icon, or an ellipsis (…). Many style guides recommend to use a minimum button width in command button bars, for example 50 dialog units on Windows. Such a minimum width makes it easier to click a button, just because the button area has a reasonable minimum size. To ensure a reasonable button minimum width, you may configure a LayoutManager, use a special panel for command button bars, or a factory that vends command button bars.

The JGoodies FormLayout can layout button bars that comply with both the MS Windows Layout Guidelines and the Mac Aqua Human Interface Guidelines. The JGoodies Forms contains a ButtonBarBuilder to build command button bars, and a ButtonBarFactory that vends frequently used button bars.

Returns:
true (default) if all buttons shall use narrow margins, false for wider margins

getUseSystemFonts

public static boolean getUseSystemFonts()
Returns whether native system fonts shall be used, true by default unless disabled in the system properties or UIManager.
Returns:
true unless disabled in the system properties or UIManager

isHiResGrayFilterEnabled

public static boolean isHiResGrayFilterEnabled()
Checks and answers whether the new high-resolution gray filter is enabled or disabled. It is enabled by default.
Returns:
true if the high-resolution gray filter is enabled, false if disabled
Since:
2.1

isPopupDropShadowActive

public static boolean isPopupDropShadowActive()
Checks and answers whether popup drop shadows are active. This feature shall be inactive with toolkits that use native drop shadows, such as Aqua on the Mac OS X. It is also inactive if the ShadowPopup cannot snapshot the desktop background (due to security and AWT exceptions). Otherwise the feature's enablement state is returned.

Currently only the Mac OS X is detected as platform where the toolkit uses native drop shadows.

Returns:
true if drop shadows are active, false if inactive

isPopupDropShadowEnabled

public static boolean isPopupDropShadowEnabled()
Checks and answers whether the optional drop shadows for PopupMenus are enabled or disabled.
Returns:
true if drop shadows are enabled, false if disabled

isSelectOnFocusGainActive

public static boolean isSelectOnFocusGainActive(JTextComponent c)
Checks and answers whether the select all on focus gain feature is active for the given field. Involves both the indiviual setting and the global default.
Parameters:
c - the component to check
Returns:
true if the feature is enabled for c or globally, false if the feature is disabled for c or globally disabled.
Since:
2.2

isSelectOnFocusGainEnabled

public static boolean isSelectOnFocusGainEnabled()
Returns:
true if the select all feature is enabled globally, false if disabled
Since:
2.2

isTabIconsEnabled

public static boolean isTabIconsEnabled()
Checks and answers if we shall use icons in JTabbedPanes. By default, tab icons are enabled. If the user has set a system property, we log a message about the choosen style.
Returns:
true if icons in tabbed panes are enabled, false if disabled

putLookAndFeelReplacement

public static void putLookAndFeelReplacement(String original,
                                             String replacement)
Puts a replacement name for a given LookAndFeel class name in the list of all look and feel replacements.
Parameters:
original - the name of the look-and-feel to replace
replacement - the name of the replacement look-and-feel

removeLookAndFeelReplacement

public static void removeLookAndFeelReplacement(String original)
Removes a replacement name for a given LookAndFeel class name from the list of all look and feel replacements.
Parameters:
original - the name of the look-and-feel that has been replaced

setDefaultIconSize

public static void setDefaultIconSize(Dimension defaultIconSize)
Sets the default icon size.
Parameters:
defaultIconSize - the default icon size to set

setHiResGrayFilterEnabled

public static void setHiResGrayFilterEnabled(boolean b)
Enables or disables the new high-resolution gray filter globally. This gray filter can be disabled for individual components using the client property key HI_RES_DISABLED_ICON_CLIENT_KEY.
Parameters:
b - true to enable the high-resolution gray filter, false to disable them
Since:
2.1

setPopupDropShadowEnabled

public static void setPopupDropShadowEnabled(boolean b)
Enables or disables drop shadows in PopupMenus. Note that drop shadows are always inactive on platforms that provide native drop shadows such as the Mac OS X.

It is recommended to enable this feature only on platforms that accelerate translucency and snapshots with the hardware.

Parameters:
b - true to enable drop shadows, false to disable them

setSelectOnFocusGainEnabled

public static void setSelectOnFocusGainEnabled(JTextField field,
                                               Boolean b)
Overrides the global default for the select all feature for the given text field.
Parameters:
field - the field to set this feature
b - Boolean.TRUE to enable, Boolean.FALSE to disable, null to use the global default
Since:
2.2

setSelectOnFocusGainEnabled

public static void setSelectOnFocusGainEnabled(boolean b)
Enables or disables the select on focus gain feature globally. This feature can be disabled for individual components using the client property key SELECT_ALL_ON_FOCUS_GAIN_CLIENT_KEY. It is enabled by default.

Background: If users are more likely going to reenter the entire value in a text field, all text shall be selected on focus gain. If users are more likely to edit a text, the caret shall be placed at the end of the text.

Parameters:
b - true to enable the select all on focus gain, false to disable this feature globally
Since:
2.2

setTabIconsEnabled

public static void setTabIconsEnabled(boolean b)
Enables or disables the use of icons in JTabbedPanes.
Parameters:
b - true to enable icons in tabbed panes, false to disable them

setUseNarrowButtons

public static void setUseNarrowButtons(boolean b)
Globally sets the use narrow or standard button margins.

In previous versions of the JGoodies Looks this setting was supported also for individual buttons - primarily to offer visual backward compatibility with Sun L&Fs.

Parameters:
b - true to use narrow button margins globally

setUseSystemFonts

public static void setUseSystemFonts(boolean useSystemFonts)
Sets a value in the UIManager to indicate, that a look&feel may use the native system fonts.
Parameters:
useSystemFonts - true to enable system fonts in the UIManager

Copyright © 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.