Package com.jgoodies.looks.plastic
Class PlasticLookAndFeel
java.lang.Object
javax.swing.LookAndFeel
javax.swing.plaf.basic.BasicLookAndFeel
javax.swing.plaf.metal.MetalLookAndFeel
com.jgoodies.looks.plastic.PlasticLookAndFeel
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Plastic3DLookAndFeel
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.46 $
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringClient property key to set a border style - shadows the header style.static final StringA System property key to set the default theme.static final StringA System property key that indicates that the high contrast focus colors shall be choosen - if applicable.private static List<PlasticTheme>The List of installed Plastic themes.static final StringClient property key to disable the pseudo 3D effect.private static booleanThe look-global state for the 3D enablement.private static booleanstatic final StringA System property value that indicates that Plastic shall render tabs in the Plastic 1.0 style.protected static final StringA System property key for the rendering style of the Plastic TabbedPane.static final StringA System property value that indicates that Plastic shall render tabs in the Metal L&F style.private static final Stringprivate static booleanHolds whether we are using the high contrast focus colors.private static booleanHolds whether Plastic uses Metal or Plastic tabbed panes. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs the PlasticLookAndFeel, creates the default theme and sets it as current Plastic theme. -
Method Summary
Modifier and TypeMethodDescriptionprivate static Object[]Appends the key and value to the given source array and returns a copy that has the two new elements at its end.static PlasticThemeCreates and returns the default color theme.protected static PlasticThemecreateTheme(String themeName) Creates and returns a color theme from the specified theme name.static ColorUIResourcestatic ColorUIResourcestatic ColorUIResourceprivate static StringgetDisabledIcon(JComponent component, Icon icon) Returns an icon with a disabled appearance.static ColorUIResourcestatic FontPolicyLooks up and retrieves the FontPolicy used by the JGoodies Plastic Look&Feel family.static booleangetID()static ListLazily initializes and returns theListof installed color themes.static BorderUIResourcestatic ColorUIResourcestatic ColorUIResourcestatic ColorUIResourcestatic MicroLayoutPolicyLooks up and retrieves the MicroLayoutPolicy used by the JGoodies Plastic Look&Fs.getName()static BorderUIResourcestatic PlasticThemeLazily initializes and returns the PlasticTheme.static ColorUIResourcestatic ColorUIResourcestatic ColorUIResourcestatic ColorUIResourcestatic ColorUIResourcestatic ColorUIResourcestatic ColorUIResourcestatic Stringstatic ColorUIResourcestatic FontUIResourcestatic ColorUIResourcestatic ColorUIResourcestatic ColorUIResourcestatic ColorUIResourceprotected voidinitClassDefaults(UIDefaults table) Initializes the class defaults, that is, overrides some UI delegates with JGoodies Plastic implementations.protected voidinitComponentDefaults(UIDefaults table) voidInvoked duringUIManager#setLookAndFeel.protected voidUnlike my superclass I register a unified shadow color.protected static voidInstall the default color themes.static voidinstallTheme(PlasticTheme theme) Installs a color theme.protected booleanstatic booleanstatic 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(MicroLayoutPolicy 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.static voidsetSelectTextOnKeyboardFocusGained(boolean b) Sets whether text field text shall be selected when it gains focus via the keyboard.static voidsetTabStyle(String tabStyle) voidInvoked duringUIManager#setLookAndFeel.Methods inherited from class javax.swing.plaf.metal.MetalLookAndFeel
createDefaultTheme, getAcceleratorForeground, getAcceleratorSelectedForeground, getBlack, getControlDisabled, getControlInfo, getControlShadow, getControlTextColor, getControlTextFont, getCurrentTheme, getDefaults, getDesktopColor, getDisabledSelectedIcon, getHighlightedTextColor, getInactiveControlTextColor, getInactiveSystemTextColor, getLayoutStyle, getMenuBackground, getMenuDisabledForeground, getMenuForeground, getMenuSelectedBackground, getMenuSelectedForeground, getMenuTextFont, getSeparatorBackground, getSeparatorForeground, getSubTextFont, getSupportsWindowDecorations, getSystemTextColor, getSystemTextFont, getTextHighlightColor, getUserTextColor, getUserTextFont, getWhite, getWindowBackground, getWindowTitleFont, isNativeLookAndFeel, isSupportedLookAndFeel, provideErrorFeedback, setCurrentThemeMethods inherited from class javax.swing.plaf.basic.BasicLookAndFeel
createAudioAction, getAudioActionMap, loadSystemColors, playSoundMethods inherited from class javax.swing.LookAndFeel
getDesktopPropertyValue, installBorder, installColors, installColorsAndFont, installProperty, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, toString, uninstallBorder
-
Field Details
-
BORDER_STYLE_KEY
Client property key to set a border style - shadows the header style.- See Also:
-
IS_3D_KEY
Client property key to disable the pseudo 3D effect.- See Also:
-
DEFAULT_THEME_KEY
A System property key to set the default theme.- See Also:
-
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.- See Also:
-
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.- See Also:
-
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.- See Also:
-
TAB_STYLE_METAL_VALUE
A System property value that indicates that Plastic shall render tabs in the Metal L&F style.- See Also:
-
useMetalTabs
private static boolean useMetalTabsHolds whether Plastic uses Metal or Plastic tabbed panes. -
useHighContrastFocusColors
private static boolean useHighContrastFocusColorsHolds whether we are using the high contrast focus colors. -
installedThemes
The List of installed Plastic themes. -
is3DEnabled
private static boolean is3DEnabledThe look-global state for the 3D enablement. -
selectTextOnKeyboardFocusGained
private static boolean selectTextOnKeyboardFocusGained -
THEME_CLASSNAME_PREFIX
- See Also:
-
-
Constructor Details
-
PlasticLookAndFeel
public PlasticLookAndFeel()Constructs the PlasticLookAndFeel, creates the default theme and sets it as current Plastic theme.
-
-
Method Details
-
getID
- Overrides:
getIDin classMetalLookAndFeel
-
getName
- Overrides:
getNamein classMetalLookAndFeel
-
getDescription
- Overrides:
getDescriptionin classMetalLookAndFeel
-
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:
-
setFontPolicy
Sets the FontPolicy to be used with the JGoodies Plastic L&F family. If the specified policy isnull, the default will be reset.- Parameters:
fontPolicy- the FontPolicy to be used with the JGoodies Plastic L&F family, ornullto reset to the default- See Also:
-
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:
-
setMicroLayoutPolicy
Sets the MicroLayoutPolicy to be used with the JGoodies Plastic L&Fs. If the specified policy isnull, the default will be reset.- Parameters:
microLayoutPolicy- the MicroLayoutPolicy to be used with the JGoodies Plastic L&Fs, ornullto reset to the default- See Also:
-
is3DEnabled
protected boolean is3DEnabled() -
set3DEnabled
public static void set3DEnabled(boolean b) -
getTabStyle
-
setTabStyle
-
getHighContrastFocusColorsEnabled
public static boolean getHighContrastFocusColorsEnabled() -
setHighContrastFocusColorsEnabled
public static void setHighContrastFocusColorsEnabled(boolean b) -
isSelectTextOnKeyboardFocusGained
public static boolean isSelectTextOnKeyboardFocusGained() -
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-trueto enabled,falseto disable
-
initialize
public void initialize()Invoked duringUIManager#setLookAndFeel. In addition to the superclass behavior, we install the ShadowPopupFactory.- Overrides:
initializein classBasicLookAndFeel- See Also:
-
uninitialize
public void uninitialize()Invoked duringUIManager#setLookAndFeel. In addition to the superclass behavior, we uninstall the ShadowPopupFactory.- Overrides:
uninitializein classBasicLookAndFeel- See Also:
-
getDisabledIcon
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.
- Overrides:
getDisabledIconin classMetalLookAndFeel- 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.
-
initClassDefaults
Initializes the class defaults, that is, overrides some UI delegates with JGoodies Plastic implementations.- Overrides:
initClassDefaultsin classMetalLookAndFeel- Parameters:
table- the UIDefaults table to work with- See Also:
-
initComponentDefaults
- Overrides:
initComponentDefaultsin classMetalLookAndFeel
-
initSystemColorDefaults
Unlike my superclass I register a unified shadow color. This color is used by my ThinBevelBorder class.- Overrides:
initSystemColorDefaultsin classMetalLookAndFeel- Parameters:
table- the UIDefaults table to work with
-
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 environment
-
getDefaultXPTheme
-
getInstalledThemes
Lazily initializes and returns theListof installed color themes.- Returns:
- a list of installed color/font themes
-
installDefaultThemes
protected static void installDefaultThemes()Install the default color themes. -
createTheme
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
nullin case of a problem
-
installTheme
Installs a color theme.- Parameters:
theme- the theme to install
-
getPlasticTheme
Lazily initializes and returns the PlasticTheme.- Returns:
- the current PlasticTheme
-
setPlasticTheme
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:
-
getInternalFrameBorder
-
getPaletteBorder
-
getPrimaryControlDarkShadow
-
getPrimaryControlHighlight
-
getPrimaryControlInfo
-
getPrimaryControlShadow
-
getPrimaryControl
-
getControlHighlight
-
getControlDarkShadow
-
getControl
-
getFocusColor
-
getMenuItemBackground
-
getMenuItemSelectedBackground
-
getMenuItemSelectedForeground
-
getWindowTitleBackground
-
getWindowTitleForeground
-
getWindowTitleInactiveBackground
-
getWindowTitleInactiveForeground
-
getSimpleInternalFrameForeground
-
getSimpleInternalFrameBackground
-
getTitleTextColor
-
getTitleTextFont
-
append
Appends the key and value to the given source array and returns a copy that has the two new elements at its end.- Returns:
- an array with the key and value appended
-