com.jgoodies.looks.plastic

Class PlasticLookAndFeel

public class PlasticLookAndFeel extends MetalLookAndFeel

The base class for the JGoodies Plastic look&feel family. Initializes class and component defaults for the Plastic L&f and provides keys and optional features for the Plastic family.

Version: $Revision: 1.36 $

Author: Karsten Lentzsch

Field Summary
static StringBORDER_STYLE_KEY
Client property key to set a border style - shadows the header style.
static StringDEFAULT_THEME_KEY
A System property key to set the default theme.
static StringHIGH_CONTRAST_FOCUS_ENABLED_KEY
A System property key that indicates that the high contrast focus colors shall be choosen - if applicable.
static StringIS_3D_KEY
Client property key to disable the pseudo 3D effect.
static StringTAB_STYLE_DEFAULT_VALUE
A System property value that indicates that Plastic shall render tabs in the Plastic 1.0 style.
protected static StringTAB_STYLE_KEY
A System property key for the rendering style of the Plastic TabbedPane.
static StringTAB_STYLE_METAL_VALUE
A System property value that indicates that Plastic shall render tabs in the Metal L&F style.
Constructor Summary
PlasticLookAndFeel()
Constructs the PlasticLookAndFeel, creates the default theme and sets it as current Plastic theme.
Method Summary
static PlasticThemecreateMyDefaultTheme()
Creates and returns the default color theme.
protected static PlasticThemecreateTheme(String themeName)
Creates and returns a color theme from the specified theme name.
static ColorUIResourcegetControl()
static ColorUIResourcegetControlDarkShadow()
static ColorUIResourcegetControlHighlight()
StringgetDescription()
IcongetDisabledIcon(JComponent component, Icon icon)
Returns an icon with a disabled appearance.
static ColorUIResourcegetFocusColor()
static FontPolicygetFontPolicy()
Looks up and retrieves the FontPolicy used by the JGoodies Plastic Look&Feel family.
static booleangetHighContrastFocusColorsEnabled()
StringgetID()
static ListgetInstalledThemes()
Lazily initializes and returns the List of installed color themes.
static BorderUIResourcegetInternalFrameBorder()
static ColorUIResourcegetMenuItemBackground()
static ColorUIResourcegetMenuItemSelectedBackground()
static ColorUIResourcegetMenuItemSelectedForeground()
static MicroLayoutPolicygetMicroLayoutPolicy()
Looks up and retrieves the MicroLayoutPolicy used by the JGoodies Plastic Look&Fs.
StringgetName()
static BorderUIResourcegetPaletteBorder()
static PlasticThemegetPlasticTheme()
Lazily initializes and returns the PlasticTheme.
static ColorUIResourcegetPrimaryControl()
static ColorUIResourcegetPrimaryControlDarkShadow()
static ColorUIResourcegetPrimaryControlHighlight()
static ColorUIResourcegetPrimaryControlInfo()
static ColorUIResourcegetPrimaryControlShadow()
static ColorUIResourcegetSimpleInternalFrameBackground()
static ColorUIResourcegetSimpleInternalFrameForeground()
static StringgetTabStyle()
static ColorUIResourcegetTitleTextColor()
static FontUIResourcegetTitleTextFont()
static ColorUIResourcegetWindowTitleBackground()
static ColorUIResourcegetWindowTitleForeground()
static ColorUIResourcegetWindowTitleInactiveBackground()
static ColorUIResourcegetWindowTitleInactiveForeground()
protected voidinitClassDefaults(UIDefaults table)
Initializes the class defaults, that is, overrides some UI delegates with JGoodies Plastic implementations.
protected voidinitComponentDefaults(UIDefaults table)
voidinitialize()
Invoked during UIManager#setLookAndFeel.
protected voidinitSystemColorDefaults(UIDefaults table)
Unlike my superclass I register a unified shadow color.
protected static voidinstallDefaultThemes()
Install the default color themes.
static voidinstallTheme(PlasticTheme theme)
Installs a color theme.
protected booleanis3DEnabled()
static booleanisSelectTextOnKeyboardFocusGained()
static voidset3DEnabled(boolean b)
static voidsetFontPolicy(FontPolicy fontPolicy)
Sets the FontPolicy to be used with the JGoodies Plastic L&F family.
static voidsetHighContrastFocusColorsEnabled(boolean b)
static voidsetMicroLayoutPolicy(MicroLayout microLayoutPolicy)
Sets the MicroLayoutPolicy to be used with the JGoodies Plastic L&Fs.
static voidsetPlasticTheme(PlasticTheme theme)
Sets the theme for colors and fonts used by the Plastic L&F.

After setting the theme, you need to re-install the Look&Feel, as well as update the UI's of any previously created components - just as if you'd change the Look&Feel.

static voidsetSelectTextOnKeyboardFocusGained(boolean b)
Sets whether text field text shall be selected when it gains focus via the keyboard.
static voidsetTabStyle(String tabStyle)
voiduninitialize()
Invoked during UIManager#setLookAndFeel.

Field Detail

BORDER_STYLE_KEY

public static final String BORDER_STYLE_KEY
Client property key to set a border style - shadows the header style.

DEFAULT_THEME_KEY

public static final String DEFAULT_THEME_KEY
A System property key to set the default theme.

HIGH_CONTRAST_FOCUS_ENABLED_KEY

public static final String HIGH_CONTRAST_FOCUS_ENABLED_KEY
A System property key that indicates that the high contrast focus colors shall be choosen - if applicable. If not set, some focus colors look good but have low contrast. Basically, the low contrast scheme uses the Plastic colors before 1.0.7, and the high contrast scheme is 1.0.7 - 1.0.9.

IS_3D_KEY

public static final String IS_3D_KEY
Client property key to disable the pseudo 3D effect.

TAB_STYLE_DEFAULT_VALUE

public static final String TAB_STYLE_DEFAULT_VALUE
A System property value that indicates that Plastic shall render tabs in the Plastic 1.0 style. This is the default.

TAB_STYLE_KEY

protected static final String TAB_STYLE_KEY
A System property key for the rendering style of the Plastic TabbedPane. Valid values are: default for the Plastic 1.0 tabs, and metal for the Metal L&F tabs.

TAB_STYLE_METAL_VALUE

public static final String TAB_STYLE_METAL_VALUE
A System property value that indicates that Plastic shall render tabs in the Metal L&F style.

Constructor Detail

PlasticLookAndFeel

public PlasticLookAndFeel()
Constructs the PlasticLookAndFeel, creates the default theme and sets it as current Plastic theme.

Method Detail

createMyDefaultTheme

public static PlasticTheme createMyDefaultTheme()
Creates and returns the default color theme. Honors the current platform and platform flavor - if available.

Returns: the default color theme for the current environemt

createTheme

protected static PlasticTheme createTheme(String themeName)
Creates and returns a color theme from the specified theme name.

Parameters: themeName the unqualified name of the theme to create

Returns: the associated color theme or null in case of a problem

getControl

public static ColorUIResource getControl()

getControlDarkShadow

public static ColorUIResource getControlDarkShadow()

getControlHighlight

public static ColorUIResource getControlHighlight()

getDescription

public String getDescription()

getDisabledIcon

public Icon getDisabledIcon(JComponent component, Icon icon)
Returns an icon with a disabled appearance. This method is used to generate a disabled icon when one has not been specified.

This method will be used only on JDK 5.0 and later.

Parameters: component the component that will display the icon, may be null. icon the icon to generate disabled icon from.

Returns: disabled icon, or null if a suitable icon can not be generated.

getFocusColor

public static ColorUIResource getFocusColor()

getFontPolicy

public static FontPolicy getFontPolicy()
Looks up and retrieves the FontPolicy used by the JGoodies Plastic Look&Feel family. If a FontPolicy has been set, it'll be returned. Otherwise, this method checks if a FontPolicy or FontSet is defined in the system properties or UIDefaults. If so, it is returned. If no FontPolicy has been set for this look, in the system properties or UIDefaults, the default Plastic font policy will be returned.

Returns: the FontPolicy set for this Look&feel - if any, the FontPolicy specified in the system properties or UIDefaults - if any, or the default Plastic font policy.

See Also: PlasticLookAndFeel PLASTIC_FONT_POLICY_KEY FontPolicies customSettingsPolicy getDefaultPlasticPolicy

getHighContrastFocusColorsEnabled

public static boolean getHighContrastFocusColorsEnabled()

getID

public String getID()

getInstalledThemes

public static List getInstalledThemes()
Lazily initializes and returns the List of installed color themes.

Returns: a list of installed color/font themes

getInternalFrameBorder

public static BorderUIResource getInternalFrameBorder()

getMenuItemBackground

public static ColorUIResource getMenuItemBackground()

getMenuItemSelectedBackground

public static ColorUIResource getMenuItemSelectedBackground()

getMenuItemSelectedForeground

public static ColorUIResource getMenuItemSelectedForeground()

getMicroLayoutPolicy

public static MicroLayoutPolicy getMicroLayoutPolicy()
Looks up and retrieves the MicroLayoutPolicy used by the JGoodies Plastic Look&Fs. If a MicroLayoutPolicy has been set for this look, it'll be returned. Otherwise, the default Plastic micro layout policy will be returned.

Returns: the MicroLayoutPolicy set for this Look&feel - if any, or the default Plastic MicroLayoutPolicy.

See Also: PlasticLookAndFeel PLASTIC_MICRO_LAYOUT_POLICY_KEY MicroLayoutPolicies

getName

public String getName()

getPaletteBorder

public static BorderUIResource getPaletteBorder()

getPlasticTheme

public static PlasticTheme getPlasticTheme()
Lazily initializes and returns the PlasticTheme. In Java 5 or later, this method looks up the theme using MetalLookAndFeel#getCurrentTheme. In Java 1.4 it is requested from the UIManager. Both access methods use an AppContext to store the theme, so that applets in different contexts don't share the theme.

Returns: the current PlasticTheme

getPrimaryControl

public static ColorUIResource getPrimaryControl()

getPrimaryControlDarkShadow

public static ColorUIResource getPrimaryControlDarkShadow()

getPrimaryControlHighlight

public static ColorUIResource getPrimaryControlHighlight()

getPrimaryControlInfo

public static ColorUIResource getPrimaryControlInfo()

getPrimaryControlShadow

public static ColorUIResource getPrimaryControlShadow()

getSimpleInternalFrameBackground

public static ColorUIResource getSimpleInternalFrameBackground()

getSimpleInternalFrameForeground

public static ColorUIResource getSimpleInternalFrameForeground()

getTabStyle

public static String getTabStyle()

getTitleTextColor

public static ColorUIResource getTitleTextColor()

getTitleTextFont

public static FontUIResource getTitleTextFont()

getWindowTitleBackground

public static ColorUIResource getWindowTitleBackground()

getWindowTitleForeground

public static ColorUIResource getWindowTitleForeground()

getWindowTitleInactiveBackground

public static ColorUIResource getWindowTitleInactiveBackground()

getWindowTitleInactiveForeground

public static ColorUIResource getWindowTitleInactiveForeground()

initClassDefaults

protected void initClassDefaults(UIDefaults table)
Initializes the class defaults, that is, overrides some UI delegates with JGoodies Plastic implementations.

Parameters: table the UIDefaults table to work with

See Also: javax.swing.plaf.basic.BasicLookAndFeel#getDefaults()

initComponentDefaults

protected void initComponentDefaults(UIDefaults table)

initialize

public void initialize()
Invoked during UIManager#setLookAndFeel. In addition to the superclass behavior, we install the ShadowPopupFactory.

See Also: PlasticLookAndFeel

initSystemColorDefaults

protected void initSystemColorDefaults(UIDefaults table)
Unlike my superclass I register a unified shadow color. This color is used by my ThinBevelBorder class.

Parameters: table the UIDefaults table to work with

installDefaultThemes

protected static void installDefaultThemes()
Install the default color themes.

installTheme

public static void installTheme(PlasticTheme theme)
Installs a color theme.

Parameters: theme the theme to install

is3DEnabled

protected boolean is3DEnabled()

isSelectTextOnKeyboardFocusGained

public static boolean isSelectTextOnKeyboardFocusGained()

set3DEnabled

public static void set3DEnabled(boolean b)

setFontPolicy

public static void setFontPolicy(FontPolicy fontPolicy)
Sets the FontPolicy to be used with the JGoodies Plastic L&F family. If the specified policy is null, the default will be reset.

Parameters: fontPolicy the FontPolicy to be used with the JGoodies Plastic L&F family, or null to reset to the default

See Also: getFontPolicy PLASTIC_FONT_POLICY_KEY

setHighContrastFocusColorsEnabled

public static void setHighContrastFocusColorsEnabled(boolean b)

setMicroLayoutPolicy

public static void setMicroLayoutPolicy(MicroLayout microLayoutPolicy)
Sets the MicroLayoutPolicy to be used with the JGoodies Plastic L&Fs. If the specified policy is null, the default will be reset.

Parameters: microLayoutPolicy the MicroLayoutPolicy to be used with the JGoodies Plastic L&Fs, or null to reset to the default

See Also: getMicroLayoutPolicy PLASTIC_MICRO_LAYOUT_POLICY_KEY

setPlasticTheme

public static void setPlasticTheme(PlasticTheme theme)
Sets the theme for colors and fonts used by the Plastic L&F.

After setting the theme, you need to re-install the Look&Feel, as well as update the UI's of any previously created components - just as if you'd change the Look&Feel.

Parameters: theme the PlasticTheme to be set

Throws: NullPointerException if the theme is null.

See Also: getPlasticTheme

setSelectTextOnKeyboardFocusGained

public static void setSelectTextOnKeyboardFocusGained(boolean b)
Sets whether text field text shall be selected when it gains focus via the keyboard. This is enabled on Windows by default and disabled on all other platforms.

Parameters: b

setTabStyle

public static void setTabStyle(String tabStyle)

uninitialize

public void uninitialize()
Invoked during UIManager#setLookAndFeel. In addition to the superclass behavior, we uninstall the ShadowPopupFactory.

See Also: PlasticLookAndFeel

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