- All Implemented Interfaces:
Serializable
public class MetalLookAndFeel extends BasicLookAndFeel
Each of the ComponentUI
s provided by
MetalLookAndFeel
derives its behavior from the defaults
table. Unless otherwise noted each of the ComponentUI
implementations in this package document the set of defaults they
use. Unless otherwise noted the defaults are installed at the time
installUI
is invoked, and follow the recommendations
outlined in LookAndFeel
for installing defaults.
MetalLookAndFeel
derives it's color palette and fonts from
MetalTheme
. The default theme is OceanTheme
. The theme
can be changed using the setCurrentTheme
method, refer to it
for details on changing the theme. Prior to 1.5 the default
theme was DefaultMetalTheme
. The system property
"swing.metalTheme"
can be set to "steel"
to indicate
the default should be DefaultMetalTheme
.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans
package.
Please see XMLEncoder
.
- See Also:
MetalTheme
,DefaultMetalTheme
,OceanTheme
-
Constructor Summary
Constructors Constructor Description MetalLookAndFeel()
-
Method Summary
Modifier and Type Method Description protected void
createDefaultTheme()
Ensures the currentMetalTheme
isnon-null
.static ColorUIResource
getAcceleratorForeground()
Returns the accelerator foreground color of the current theme.static ColorUIResource
getAcceleratorSelectedForeground()
Returns the accelerator selected foreground color of the current theme.static ColorUIResource
getBlack()
Returns the black color of the current theme.static ColorUIResource
getControl()
Returns the control color of the current theme.static ColorUIResource
getControlDarkShadow()
Returns the control dark shadow color of the current theme.static ColorUIResource
getControlDisabled()
Returns the control disabled color of the current theme.static ColorUIResource
getControlHighlight()
Returns the control highlight color of the current theme.static ColorUIResource
getControlInfo()
Returns the control info color of the current theme.static ColorUIResource
getControlShadow()
Returns the control shadow color of the current theme.static ColorUIResource
getControlTextColor()
Returns the control text color of the current theme.static FontUIResource
getControlTextFont()
Returns the control text font of the current theme.static MetalTheme
getCurrentTheme()
Return the theme currently being used byMetalLookAndFeel
.UIDefaults
getDefaults()
Returns the look and feel defaults.String
getDescription()
Returns a short description of this look and feel.static ColorUIResource
getDesktopColor()
Returns the desktop color of the current theme.Icon
getDisabledIcon(JComponent component, Icon icon)
Returns anIcon
with a disabled appearance.Icon
getDisabledSelectedIcon(JComponent component, Icon icon)
Returns anIcon
for use by disabled components that are also selected.static ColorUIResource
getFocusColor()
Returns the focus color of the current theme.static ColorUIResource
getHighlightedTextColor()
Returns the highlighted text color of the current theme.String
getID()
Returns an identifier for this look and feel.static ColorUIResource
getInactiveControlTextColor()
Returns the inactive control text color of the current theme.static ColorUIResource
getInactiveSystemTextColor()
Returns the inactive system text color of the current theme.LayoutStyle
getLayoutStyle()
Returns aLayoutStyle
implementing the Java look and feel design guidelines as specified at http://www.oracle.com/technetwork/java/hig-136467.html.static ColorUIResource
getMenuBackground()
Returns the menu background color of the current theme.static ColorUIResource
getMenuDisabledForeground()
Returns the menu disabled foreground color of the current theme.static ColorUIResource
getMenuForeground()
Returns the menu foreground color of the current theme.static ColorUIResource
getMenuSelectedBackground()
Returns the menu selected background color of the current theme.static ColorUIResource
getMenuSelectedForeground()
Returns the menu selected foreground color of the current theme.static FontUIResource
getMenuTextFont()
Returns the menu text font of the current theme.String
getName()
Returns the name of this look and feel.static ColorUIResource
getPrimaryControl()
Returns the primary control color of the current theme.static ColorUIResource
getPrimaryControlDarkShadow()
Returns the primary control dark shadow color of the current theme.static ColorUIResource
getPrimaryControlHighlight()
Returns the primary control highlight color of the current theme.static ColorUIResource
getPrimaryControlInfo()
Returns the primary control info color of the current theme.static ColorUIResource
getPrimaryControlShadow()
Returns the primary control shadow color of the current theme.static ColorUIResource
getSeparatorBackground()
Returns the separator background color of the current theme.static ColorUIResource
getSeparatorForeground()
Returns the separator foreground color of the current theme.static FontUIResource
getSubTextFont()
Returns the sub-text font of the current theme.boolean
getSupportsWindowDecorations()
Returnstrue
; metal can provideWindow
decorations.static ColorUIResource
getSystemTextColor()
Returns the system text color of the current theme.static FontUIResource
getSystemTextFont()
Returns the system text font of the current theme.static ColorUIResource
getTextHighlightColor()
Returns the text highlight color of the current theme.static ColorUIResource
getUserTextColor()
Returns the user text color of the current theme.static FontUIResource
getUserTextFont()
Returns the user text font of the current theme.static ColorUIResource
getWhite()
Returns the white color of the current theme.static ColorUIResource
getWindowBackground()
Returns the window background color of the current theme.static ColorUIResource
getWindowTitleBackground()
Returns the window title background color of the current theme.static FontUIResource
getWindowTitleFont()
Returns the window title font of the current theme.static ColorUIResource
getWindowTitleForeground()
Returns the window title foreground color of the current theme.static ColorUIResource
getWindowTitleInactiveBackground()
Returns the window title inactive background color of the current theme.static ColorUIResource
getWindowTitleInactiveForeground()
Returns the window title inactive foreground color of the current theme.protected void
initClassDefaults(UIDefaults table)
Populatestable
with mappings fromuiClassID
to the fully qualified name of the ui class.protected void
initComponentDefaults(UIDefaults table)
Populatestable
with the defaults for metal.protected void
initSystemColorDefaults(UIDefaults table)
Populatestable
with system colors.boolean
isNativeLookAndFeel()
Returnsfalse
;MetalLookAndFeel
is not a native look and feel.boolean
isSupportedLookAndFeel()
Returnstrue
;MetalLookAndFeel
can be run on any platform.void
provideErrorFeedback(Component component)
Invoked when the user attempts an invalid operation, such as pasting into an uneditableJTextField
that has focus.static void
setCurrentTheme(MetalTheme theme)
Set the theme used byMetalLookAndFeel
.Methods declared in class javax.swing.plaf.basic.BasicLookAndFeel
createAudioAction, getAudioActionMap, loadSystemColors, playSound
Methods declared in class javax.swing.LookAndFeel
getDesktopPropertyValue, initialize, installBorder, installColors, installColorsAndFont, installProperty, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, toString, uninitialize, uninstallBorder
-
Constructor Details
-
MetalLookAndFeel
public MetalLookAndFeel()
-
-
Method Details
-
getName
Returns the name of this look and feel. This returns"Metal"
.- Specified by:
getName
in classLookAndFeel
- Returns:
- the name of this look and feel
-
getID
Returns an identifier for this look and feel. This returns"Metal"
.- Specified by:
getID
in classLookAndFeel
- Returns:
- the identifier of this look and feel
-
getDescription
Returns a short description of this look and feel. This returns"The Java(tm) Look and Feel"
.- Specified by:
getDescription
in classLookAndFeel
- Returns:
- a short description for the look and feel
-
isNativeLookAndFeel
public boolean isNativeLookAndFeel()Returnsfalse
;MetalLookAndFeel
is not a native look and feel.- Specified by:
isNativeLookAndFeel
in classLookAndFeel
- Returns:
false
-
isSupportedLookAndFeel
public boolean isSupportedLookAndFeel()Returnstrue
;MetalLookAndFeel
can be run on any platform.- Specified by:
isSupportedLookAndFeel
in classLookAndFeel
- Returns:
true
- See Also:
UIManager.setLookAndFeel(javax.swing.LookAndFeel)
-
getSupportsWindowDecorations
public boolean getSupportsWindowDecorations()Returnstrue
; metal can provideWindow
decorations.- Overrides:
getSupportsWindowDecorations
in classLookAndFeel
- Returns:
true
- Since:
- 1.4
- See Also:
JDialog.setDefaultLookAndFeelDecorated(boolean)
,JFrame.setDefaultLookAndFeelDecorated(boolean)
,JRootPane.setWindowDecorationStyle(int)
-
initClassDefaults
Populatestable
with mappings fromuiClassID
to the fully qualified name of the ui class.MetalLookAndFeel
registers an entry for each of the classes in the packagejavax.swing.plaf.metal
that are named MetalXXXUI. The stringXXX
is one of Swing's uiClassIDs. For theuiClassIDs
that do not have a class in metal, the corresponding class injavax.swing.plaf.basic
is used. For example, metal does not have a class named"MetalColorChooserUI"
, as such,javax.swing.plaf.basic.BasicColorChooserUI
is used.- Overrides:
initClassDefaults
in classBasicLookAndFeel
- Parameters:
table
- theUIDefaults
instance the entries are added to- Throws:
NullPointerException
- iftable
isnull
- See Also:
BasicLookAndFeel.initClassDefaults(javax.swing.UIDefaults)
-
initSystemColorDefaults
Populatestable
with system colors. The following values are added totable
:Metal's system color mapping Key Value "desktop" theme.getDesktopColor()
"activeCaption" theme.getWindowTitleBackground()
"activeCaptionText" theme.getWindowTitleForeground()
"activeCaptionBorder" theme.getPrimaryControlShadow()
"inactiveCaption" theme.getWindowTitleInactiveBackground()
"inactiveCaptionText" theme.getWindowTitleInactiveForeground()
"inactiveCaptionBorder" theme.getControlShadow()
"window" theme.getWindowBackground()
"windowBorder" theme.getControl()
"windowText" theme.getUserTextColor()
"menu" theme.getMenuBackground()
"menuText" theme.getMenuForeground()
"text" theme.getWindowBackground()
"textText" theme.getUserTextColor()
"textHighlight" theme.getTextHighlightColor()
"textHighlightText" theme.getHighlightedTextColor()
"textInactiveText" theme.getInactiveSystemTextColor()
"control" theme.getControl()
"controlText" theme.getControlTextColor()
"controlHighlight" theme.getControlHighlight()
"controlLtHighlight" theme.getControlHighlight()
"controlShadow" theme.getControlShadow()
"controlDkShadow" theme.getControlDarkShadow()
"scrollbar" theme.getControl()
"info" theme.getPrimaryControl()
"infoText" theme.getPrimaryControlInfo()
theme
corresponds to the currentMetalTheme
.- Overrides:
initSystemColorDefaults
in classBasicLookAndFeel
- Parameters:
table
- theUIDefaults
object the values are added to- Throws:
NullPointerException
- iftable
isnull
- See Also:
SystemColor
,BasicLookAndFeel.getDefaults()
,BasicLookAndFeel.loadSystemColors(javax.swing.UIDefaults, java.lang.String[], boolean)
-
initComponentDefaults
Populatestable
with the defaults for metal.- Overrides:
initComponentDefaults
in classBasicLookAndFeel
- Parameters:
table
- theUIDefaults
to add the values to- Throws:
NullPointerException
- iftable
isnull
-
createDefaultTheme
protected void createDefaultTheme()Ensures the currentMetalTheme
isnon-null
. This is a cover method forgetCurrentTheme
.- See Also:
getCurrentTheme()
-
getDefaults
Returns the look and feel defaults. This invokes, in order,createDefaultTheme()
,super.getDefaults()
andgetCurrentTheme().addCustomEntriesToTable(table)
.While this method is public, it should only be invoked by the
UIManager
when the look and feel is set as the current look and feel and afterinitialize
has been invoked.- Overrides:
getDefaults
in classBasicLookAndFeel
- Returns:
- the look and feel defaults
- See Also:
createDefaultTheme()
,BasicLookAndFeel.getDefaults()
,MetalTheme.addCustomEntriesToTable(UIDefaults)
-
provideErrorFeedback
Invoked when the user attempts an invalid operation, such as pasting into an uneditableJTextField
that has focus. The default implementation beeps. Subclasses that wish different behavior should override this and provide the additional feedback.- Overrides:
provideErrorFeedback
in classLookAndFeel
- Parameters:
component
- theComponent
the error occurred in, may benull
indicating the error condition is not directly associated with aComponent
- Since:
- 1.4
-
setCurrentTheme
Set the theme used byMetalLookAndFeel
.After the theme is set,
MetalLookAndFeel
needs to be re-installed and the uis need to be recreated. The following shows how to do this:MetalLookAndFeel.setCurrentTheme(theme); // re-install the Metal Look and Feel UIManager.setLookAndFeel(new MetalLookAndFeel()); // Update the ComponentUIs for all Components. This // needs to be invoked for all windows. SwingUtilities.updateComponentTreeUI(rootComponent);
If this is not done the results are undefined.- Parameters:
theme
- the theme to use- Throws:
NullPointerException
- iftheme
isnull
- See Also:
getCurrentTheme()
-
getCurrentTheme
Return the theme currently being used byMetalLookAndFeel
. If the current theme isnull
, the default theme is created.- Returns:
- the current theme
- Since:
- 1.5
- See Also:
setCurrentTheme(javax.swing.plaf.metal.MetalTheme)
-
getDisabledIcon
Returns anIcon
with a disabled appearance. This method is used to generate a disabledIcon
when one has not been specified. For example, if you create aJButton
and only specify anIcon
viasetIcon
this method will be called to generate the disabledIcon
. If null is passed asicon
this method returns null.Some look and feels might not render the disabled Icon, in which case they will ignore this.
- Overrides:
getDisabledIcon
in classLookAndFeel
- Parameters:
component
- JComponent that will display the Icon, may be nullicon
- Icon to generate disable icon from.- Returns:
- Disabled icon, or null if a suitable Icon can not be generated.
- Since:
- 1.5
-
getDisabledSelectedIcon
Returns anIcon
for use by disabled components that are also selected. This method is used to generate anIcon
for components that are in both the disabled and selected states but do not have a specificIcon
for this state. For example, if you create aJButton
and only specify anIcon
viasetIcon
this method will be called to generate the disabled and selectedIcon
. If null is passed asicon
this method returns null.Some look and feels might not render the disabled and selected Icon, in which case they will ignore this.
- Overrides:
getDisabledSelectedIcon
in classLookAndFeel
- Parameters:
component
- JComponent that will display the Icon, may be nullicon
- Icon to generate disabled and selected icon from.- Returns:
- Disabled and Selected icon, or null if a suitable Icon can not be generated.
- Since:
- 1.5
-
getControlTextFont
Returns the control text font of the current theme. This is a cover method forgetCurrentTheme().getControlTextColor()
.- Returns:
- the control text font
- See Also:
MetalTheme
-
getSystemTextFont
Returns the system text font of the current theme. This is a cover method forgetCurrentTheme().getSystemTextFont()
.- Returns:
- the system text font
- See Also:
MetalTheme
-
getUserTextFont
Returns the user text font of the current theme. This is a cover method forgetCurrentTheme().getUserTextFont()
.- Returns:
- the user text font
- See Also:
MetalTheme
-
getMenuTextFont
Returns the menu text font of the current theme. This is a cover method forgetCurrentTheme().getMenuTextFont()
.- Returns:
- the menu text font
- See Also:
MetalTheme
-
getWindowTitleFont
Returns the window title font of the current theme. This is a cover method forgetCurrentTheme().getWindowTitleFont()
.- Returns:
- the window title font
- See Also:
MetalTheme
-
getSubTextFont
Returns the sub-text font of the current theme. This is a cover method forgetCurrentTheme().getSubTextFont()
.- Returns:
- the sub-text font
- See Also:
MetalTheme
-
getDesktopColor
Returns the desktop color of the current theme. This is a cover method forgetCurrentTheme().getDesktopColor()
.- Returns:
- the desktop color
- See Also:
MetalTheme
-
getFocusColor
Returns the focus color of the current theme. This is a cover method forgetCurrentTheme().getFocusColor()
.- Returns:
- the focus color
- See Also:
MetalTheme
-
getWhite
Returns the white color of the current theme. This is a cover method forgetCurrentTheme().getWhite()
.- Returns:
- the white color
- See Also:
MetalTheme
-
getBlack
Returns the black color of the current theme. This is a cover method forgetCurrentTheme().getBlack()
.- Returns:
- the black color
- See Also:
MetalTheme
-
getControl
Returns the control color of the current theme. This is a cover method forgetCurrentTheme().getControl()
.- Returns:
- the control color
- See Also:
MetalTheme
-
getControlShadow
Returns the control shadow color of the current theme. This is a cover method forgetCurrentTheme().getControlShadow()
.- Returns:
- the control shadow color
- See Also:
MetalTheme
-
getControlDarkShadow
Returns the control dark shadow color of the current theme. This is a cover method forgetCurrentTheme().getControlDarkShadow()
.- Returns:
- the control dark shadow color
- See Also:
MetalTheme
-
getControlInfo
Returns the control info color of the current theme. This is a cover method forgetCurrentTheme().getControlInfo()
.- Returns:
- the control info color
- See Also:
MetalTheme
-
getControlHighlight
Returns the control highlight color of the current theme. This is a cover method forgetCurrentTheme().getControlHighlight()
.- Returns:
- the control highlight color
- See Also:
MetalTheme
-
getControlDisabled
Returns the control disabled color of the current theme. This is a cover method forgetCurrentTheme().getControlDisabled()
.- Returns:
- the control disabled color
- See Also:
MetalTheme
-
getPrimaryControl
Returns the primary control color of the current theme. This is a cover method forgetCurrentTheme().getPrimaryControl()
.- Returns:
- the primary control color
- See Also:
MetalTheme
-
getPrimaryControlShadow
Returns the primary control shadow color of the current theme. This is a cover method forgetCurrentTheme().getPrimaryControlShadow()
.- Returns:
- the primary control shadow color
- See Also:
MetalTheme
-
getPrimaryControlDarkShadow
Returns the primary control dark shadow color of the current theme. This is a cover method forgetCurrentTheme().getPrimaryControlDarkShadow()
.- Returns:
- the primary control dark shadow color
- See Also:
MetalTheme
-
getPrimaryControlInfo
Returns the primary control info color of the current theme. This is a cover method forgetCurrentTheme().getPrimaryControlInfo()
.- Returns:
- the primary control info color
- See Also:
MetalTheme
-
getPrimaryControlHighlight
Returns the primary control highlight color of the current theme. This is a cover method forgetCurrentTheme().getPrimaryControlHighlight()
.- Returns:
- the primary control highlight color
- See Also:
MetalTheme
-
getSystemTextColor
Returns the system text color of the current theme. This is a cover method forgetCurrentTheme().getSystemTextColor()
.- Returns:
- the system text color
- See Also:
MetalTheme
-
getControlTextColor
Returns the control text color of the current theme. This is a cover method forgetCurrentTheme().getControlTextColor()
.- Returns:
- the control text color
- See Also:
MetalTheme
-
getInactiveControlTextColor
Returns the inactive control text color of the current theme. This is a cover method forgetCurrentTheme().getInactiveControlTextColor()
.- Returns:
- the inactive control text color
- See Also:
MetalTheme
-
getInactiveSystemTextColor
Returns the inactive system text color of the current theme. This is a cover method forgetCurrentTheme().getInactiveSystemTextColor()
.- Returns:
- the inactive system text color
- See Also:
MetalTheme
-
getUserTextColor
Returns the user text color of the current theme. This is a cover method forgetCurrentTheme().getUserTextColor()
.- Returns:
- the user text color
- See Also:
MetalTheme
-
getTextHighlightColor
Returns the text highlight color of the current theme. This is a cover method forgetCurrentTheme().getTextHighlightColor()
.- Returns:
- the text highlight color
- See Also:
MetalTheme
-
getHighlightedTextColor
Returns the highlighted text color of the current theme. This is a cover method forgetCurrentTheme().getHighlightedTextColor()
.- Returns:
- the highlighted text color
- See Also:
MetalTheme
-
getWindowBackground
Returns the window background color of the current theme. This is a cover method forgetCurrentTheme().getWindowBackground()
.- Returns:
- the window background color
- See Also:
MetalTheme
-
getWindowTitleBackground
Returns the window title background color of the current theme. This is a cover method forgetCurrentTheme().getWindowTitleBackground()
.- Returns:
- the window title background color
- See Also:
MetalTheme
-
getWindowTitleForeground
Returns the window title foreground color of the current theme. This is a cover method forgetCurrentTheme().getWindowTitleForeground()
.- Returns:
- the window title foreground color
- See Also:
MetalTheme
-
getWindowTitleInactiveBackground
Returns the window title inactive background color of the current theme. This is a cover method forgetCurrentTheme().getWindowTitleInactiveBackground()
.- Returns:
- the window title inactive background color
- See Also:
MetalTheme
-
getWindowTitleInactiveForeground
Returns the window title inactive foreground color of the current theme. This is a cover method forgetCurrentTheme().getWindowTitleInactiveForeground()
.- Returns:
- the window title inactive foreground color
- See Also:
MetalTheme
-
getMenuBackground
Returns the menu background color of the current theme. This is a cover method forgetCurrentTheme().getMenuBackground()
.- Returns:
- the menu background color
- See Also:
MetalTheme
-
getMenuForeground
Returns the menu foreground color of the current theme. This is a cover method forgetCurrentTheme().getMenuForeground()
.- Returns:
- the menu foreground color
- See Also:
MetalTheme
-
getMenuSelectedBackground
Returns the menu selected background color of the current theme. This is a cover method forgetCurrentTheme().getMenuSelectedBackground()
.- Returns:
- the menu selected background color
- See Also:
MetalTheme
-
getMenuSelectedForeground
Returns the menu selected foreground color of the current theme. This is a cover method forgetCurrentTheme().getMenuSelectedForeground()
.- Returns:
- the menu selected foreground color
- See Also:
MetalTheme
-
getMenuDisabledForeground
Returns the menu disabled foreground color of the current theme. This is a cover method forgetCurrentTheme().getMenuDisabledForeground()
.- Returns:
- the menu disabled foreground color
- See Also:
MetalTheme
-
getSeparatorBackground
Returns the separator background color of the current theme. This is a cover method forgetCurrentTheme().getSeparatorBackground()
.- Returns:
- the separator background color
- See Also:
MetalTheme
-
getSeparatorForeground
Returns the separator foreground color of the current theme. This is a cover method forgetCurrentTheme().getSeparatorForeground()
.- Returns:
- the separator foreground color
- See Also:
MetalTheme
-
getAcceleratorForeground
Returns the accelerator foreground color of the current theme. This is a cover method forgetCurrentTheme().getAcceleratorForeground()
.- Returns:
- the separator accelerator foreground color
- See Also:
MetalTheme
-
getAcceleratorSelectedForeground
Returns the accelerator selected foreground color of the current theme. This is a cover method forgetCurrentTheme().getAcceleratorSelectedForeground()
.- Returns:
- the accelerator selected foreground color
- See Also:
MetalTheme
-
getLayoutStyle
Returns aLayoutStyle
implementing the Java look and feel design guidelines as specified at http://www.oracle.com/technetwork/java/hig-136467.html.- Overrides:
getLayoutStyle
in classLookAndFeel
- Returns:
- LayoutStyle implementing the Java look and feel design guidelines
- Since:
- 1.6
- See Also:
LayoutStyle.getInstance()
-