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:
java.io.Serializable
- Direct Known Subclasses:
Plastic3DLookAndFeel
public class PlasticLookAndFeel extends javax.swing.plaf.metal.MetalLookAndFeelThe 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBORDER_STYLE_KEYClient property key to set a border style - shadows the header style.static java.lang.StringDEFAULT_THEME_KEYA System property key to set the default theme.static java.lang.StringHIGH_CONTRAST_FOCUS_ENABLED_KEYA System property key that indicates that the high contrast focus colors shall be choosen - if applicable.private static java.util.List<PlasticTheme>installedThemesThe List of installed Plastic themes.static java.lang.StringIS_3D_KEYClient property key to disable the pseudo 3D effect.private static booleanis3DEnabledThe look-global state for the 3D enablement.private static booleanselectTextOnKeyboardFocusGainedstatic java.lang.StringTAB_STYLE_DEFAULT_VALUEA System property value that indicates that Plastic shall render tabs in the Plastic 1.0 style.protected static java.lang.StringTAB_STYLE_KEYA System property key for the rendering style of the Plastic TabbedPane.static java.lang.StringTAB_STYLE_METAL_VALUEA System property value that indicates that Plastic shall render tabs in the Metal L&F style.private static java.lang.StringTHEME_CLASSNAME_PREFIXprivate static booleanuseHighContrastFocusColorsHolds whether we are using the high contrast focus colors.private static booleanuseMetalTabsHolds whether Plastic uses Metal or Plastic tabbed panes.
-
Constructor Summary
Constructors Constructor Description PlasticLookAndFeel()Constructs the PlasticLookAndFeel, creates the default theme and sets it as current Plastic theme.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.Object[]append(java.lang.Object[] source, java.lang.String key, java.lang.Object value)Appends the key and value to the given source array and returns a copy that has the two new elements at its end.static PlasticThemecreateMyDefaultTheme()Creates and returns the default color theme.protected static PlasticThemecreateTheme(java.lang.String themeName)Creates and returns a color theme from the specified theme name.static javax.swing.plaf.ColorUIResourcegetControl()static javax.swing.plaf.ColorUIResourcegetControlDarkShadow()static javax.swing.plaf.ColorUIResourcegetControlHighlight()private static java.lang.StringgetDefaultXPTheme()java.lang.StringgetDescription()javax.swing.IcongetDisabledIcon(javax.swing.JComponent component, javax.swing.Icon icon)Returns an icon with a disabled appearance.static javax.swing.plaf.ColorUIResourcegetFocusColor()static FontPolicygetFontPolicy()Looks up and retrieves the FontPolicy used by the JGoodies Plastic Look&Feel family.static booleangetHighContrastFocusColorsEnabled()java.lang.StringgetID()static java.util.ListgetInstalledThemes()Lazily initializes and returns theListof installed color themes.static javax.swing.plaf.BorderUIResourcegetInternalFrameBorder()static javax.swing.plaf.ColorUIResourcegetMenuItemBackground()static javax.swing.plaf.ColorUIResourcegetMenuItemSelectedBackground()static javax.swing.plaf.ColorUIResourcegetMenuItemSelectedForeground()static MicroLayoutPolicygetMicroLayoutPolicy()Looks up and retrieves the MicroLayoutPolicy used by the JGoodies Plastic Look&Fs.java.lang.StringgetName()static javax.swing.plaf.BorderUIResourcegetPaletteBorder()static PlasticThemegetPlasticTheme()Lazily initializes and returns the PlasticTheme.static javax.swing.plaf.ColorUIResourcegetPrimaryControl()static javax.swing.plaf.ColorUIResourcegetPrimaryControlDarkShadow()static javax.swing.plaf.ColorUIResourcegetPrimaryControlHighlight()static javax.swing.plaf.ColorUIResourcegetPrimaryControlInfo()static javax.swing.plaf.ColorUIResourcegetPrimaryControlShadow()static javax.swing.plaf.ColorUIResourcegetSimpleInternalFrameBackground()static javax.swing.plaf.ColorUIResourcegetSimpleInternalFrameForeground()static java.lang.StringgetTabStyle()static javax.swing.plaf.ColorUIResourcegetTitleTextColor()static javax.swing.plaf.FontUIResourcegetTitleTextFont()static javax.swing.plaf.ColorUIResourcegetWindowTitleBackground()static javax.swing.plaf.ColorUIResourcegetWindowTitleForeground()static javax.swing.plaf.ColorUIResourcegetWindowTitleInactiveBackground()static javax.swing.plaf.ColorUIResourcegetWindowTitleInactiveForeground()protected voidinitClassDefaults(javax.swing.UIDefaults table)Initializes the class defaults, that is, overrides some UI delegates with JGoodies Plastic implementations.protected voidinitComponentDefaults(javax.swing.UIDefaults table)voidinitialize()Invoked duringUIManager#setLookAndFeel.protected voidinitSystemColorDefaults(javax.swing.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.static voidsetSelectTextOnKeyboardFocusGained(boolean b)Sets whether text field text shall be selected when it gains focus via the keyboard.static voidsetTabStyle(java.lang.String tabStyle)voiduninitialize()Invoked 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, setCurrentTheme
-
Methods inherited from class javax.swing.plaf.basic.BasicLookAndFeel
createAudioAction, getAudioActionMap, loadSystemColors, playSound
-
-
-
-
Field Detail
-
BORDER_STYLE_KEY
public static final java.lang.String BORDER_STYLE_KEY
Client property key to set a border style - shadows the header style.- See Also:
- Constant Field Values
-
IS_3D_KEY
public static final java.lang.String IS_3D_KEY
Client property key to disable the pseudo 3D effect.- See Also:
- Constant Field Values
-
DEFAULT_THEME_KEY
public static final java.lang.String DEFAULT_THEME_KEY
A System property key to set the default theme.- See Also:
- Constant Field Values
-
HIGH_CONTRAST_FOCUS_ENABLED_KEY
public static final java.lang.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.- See Also:
- Constant Field Values
-
TAB_STYLE_KEY
protected static final java.lang.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.- See Also:
- Constant Field Values
-
TAB_STYLE_DEFAULT_VALUE
public static final java.lang.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.- See Also:
- Constant Field Values
-
TAB_STYLE_METAL_VALUE
public static final java.lang.String TAB_STYLE_METAL_VALUE
A System property value that indicates that Plastic shall render tabs in the Metal L&F style.- See Also:
- Constant Field Values
-
useMetalTabs
private static boolean useMetalTabs
Holds whether Plastic uses Metal or Plastic tabbed panes.
-
useHighContrastFocusColors
private static boolean useHighContrastFocusColors
Holds whether we are using the high contrast focus colors.
-
installedThemes
private static java.util.List<PlasticTheme> installedThemes
The List of installed Plastic themes.
-
is3DEnabled
private static boolean is3DEnabled
The look-global state for the 3D enablement.
-
selectTextOnKeyboardFocusGained
private static boolean selectTextOnKeyboardFocusGained
-
THEME_CLASSNAME_PREFIX
private static final java.lang.String THEME_CLASSNAME_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
getID
public java.lang.String getID()
- Overrides:
getIDin classjavax.swing.plaf.metal.MetalLookAndFeel
-
getName
public java.lang.String getName()
- Overrides:
getNamein classjavax.swing.plaf.metal.MetalLookAndFeel
-
getDescription
public java.lang.String getDescription()
- Overrides:
getDescriptionin classjavax.swing.plaf.metal.MetalLookAndFeel
-
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:
setFontPolicy(com.jgoodies.looks.FontPolicy),Options.PLASTIC_FONT_POLICY_KEY,FontPolicies,FontPolicies.customSettingsPolicy(FontPolicy),FontPolicies.getDefaultPlasticPolicy()
-
setFontPolicy
public static void setFontPolicy(FontPolicy fontPolicy)
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:
getFontPolicy(),Options.PLASTIC_FONT_POLICY_KEY
-
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:
setMicroLayoutPolicy(com.jgoodies.looks.MicroLayout),Options.PLASTIC_MICRO_LAYOUT_POLICY_KEY,MicroLayoutPolicies
-
setMicroLayoutPolicy
public static void setMicroLayoutPolicy(MicroLayout microLayoutPolicy)
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:
getMicroLayoutPolicy(),Options.PLASTIC_MICRO_LAYOUT_POLICY_KEY
-
is3DEnabled
protected boolean is3DEnabled()
-
set3DEnabled
public static void set3DEnabled(boolean b)
-
getTabStyle
public static java.lang.String getTabStyle()
-
setTabStyle
public static void setTabStyle(java.lang.String tabStyle)
-
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 classjavax.swing.plaf.basic.BasicLookAndFeel- See Also:
uninitialize()
-
uninitialize
public void uninitialize()
Invoked duringUIManager#setLookAndFeel. In addition to the superclass behavior, we uninstall the ShadowPopupFactory.- Overrides:
uninitializein classjavax.swing.plaf.basic.BasicLookAndFeel- See Also:
initialize()
-
getDisabledIcon
public javax.swing.Icon getDisabledIcon(javax.swing.JComponent component, javax.swing.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.
- Overrides:
getDisabledIconin classjavax.swing.plaf.metal.MetalLookAndFeel- 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
protected void initClassDefaults(javax.swing.UIDefaults table)
Initializes the class defaults, that is, overrides some UI delegates with JGoodies Plastic implementations.- Overrides:
initClassDefaultsin classjavax.swing.plaf.metal.MetalLookAndFeel- Parameters:
table- the UIDefaults table to work with- See Also:
BasicLookAndFeel.getDefaults()
-
initComponentDefaults
protected void initComponentDefaults(javax.swing.UIDefaults table)
- Overrides:
initComponentDefaultsin classjavax.swing.plaf.metal.MetalLookAndFeel
-
initSystemColorDefaults
protected void initSystemColorDefaults(javax.swing.UIDefaults table)
Unlike my superclass I register a unified shadow color. This color is used by my ThinBevelBorder class.- Overrides:
initSystemColorDefaultsin classjavax.swing.plaf.metal.MetalLookAndFeel- Parameters:
table- the UIDefaults table to work with
-
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 environment
-
getDefaultXPTheme
private static java.lang.String getDefaultXPTheme()
-
getInstalledThemes
public static java.util.List 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
protected static PlasticTheme createTheme(java.lang.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
nullin case of a problem
-
installTheme
public static void installTheme(PlasticTheme theme)
Installs a color theme.- Parameters:
theme- the theme to install
-
getPlasticTheme
public static PlasticTheme getPlasticTheme()
Lazily initializes and returns the PlasticTheme.- Returns:
- the current PlasticTheme
-
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:
java.lang.NullPointerException- if the theme is null.- See Also:
getPlasticTheme()
-
getInternalFrameBorder
public static javax.swing.plaf.BorderUIResource getInternalFrameBorder()
-
getPaletteBorder
public static javax.swing.plaf.BorderUIResource getPaletteBorder()
-
getPrimaryControlDarkShadow
public static javax.swing.plaf.ColorUIResource getPrimaryControlDarkShadow()
-
getPrimaryControlHighlight
public static javax.swing.plaf.ColorUIResource getPrimaryControlHighlight()
-
getPrimaryControlInfo
public static javax.swing.plaf.ColorUIResource getPrimaryControlInfo()
-
getPrimaryControlShadow
public static javax.swing.plaf.ColorUIResource getPrimaryControlShadow()
-
getPrimaryControl
public static javax.swing.plaf.ColorUIResource getPrimaryControl()
-
getControlHighlight
public static javax.swing.plaf.ColorUIResource getControlHighlight()
-
getControlDarkShadow
public static javax.swing.plaf.ColorUIResource getControlDarkShadow()
-
getControl
public static javax.swing.plaf.ColorUIResource getControl()
-
getFocusColor
public static javax.swing.plaf.ColorUIResource getFocusColor()
-
getMenuItemBackground
public static javax.swing.plaf.ColorUIResource getMenuItemBackground()
-
getMenuItemSelectedBackground
public static javax.swing.plaf.ColorUIResource getMenuItemSelectedBackground()
-
getMenuItemSelectedForeground
public static javax.swing.plaf.ColorUIResource getMenuItemSelectedForeground()
-
getWindowTitleBackground
public static javax.swing.plaf.ColorUIResource getWindowTitleBackground()
-
getWindowTitleForeground
public static javax.swing.plaf.ColorUIResource getWindowTitleForeground()
-
getWindowTitleInactiveBackground
public static javax.swing.plaf.ColorUIResource getWindowTitleInactiveBackground()
-
getWindowTitleInactiveForeground
public static javax.swing.plaf.ColorUIResource getWindowTitleInactiveForeground()
-
getSimpleInternalFrameForeground
public static javax.swing.plaf.ColorUIResource getSimpleInternalFrameForeground()
-
getSimpleInternalFrameBackground
public static javax.swing.plaf.ColorUIResource getSimpleInternalFrameBackground()
-
getTitleTextColor
public static javax.swing.plaf.ColorUIResource getTitleTextColor()
-
getTitleTextFont
public static javax.swing.plaf.FontUIResource getTitleTextFont()
-
append
private static java.lang.Object[] append(java.lang.Object[] source, java.lang.String key, java.lang.Object value)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
-
-