public class MetalLookAndFeel extends BasicLookAndFeel
Each of the ComponentUIs 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.
MetalTheme,
DefaultMetalTheme,
OceanTheme| Constructor and Description |
|---|
MetalLookAndFeel() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
createDefaultTheme()
Ensures the current
MetalTheme is non-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 by
MetalLookAndFeel. |
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 an
Icon with a disabled appearance. |
Icon |
getDisabledSelectedIcon(JComponent component,
Icon icon)
Returns an
Icon 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 a
LayoutStyle 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()
Returns
true; metal can provide Window
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)
Populates
table with mappings from uiClassID to
the fully qualified name of the ui class. |
protected void |
initComponentDefaults(UIDefaults table)
Populates
table with the defaults for metal. |
protected void |
initSystemColorDefaults(UIDefaults table)
Populates
table with system colors. |
boolean |
isNativeLookAndFeel()
Returns
false; MetalLookAndFeel is not a native
look and feel. |
boolean |
isSupportedLookAndFeel()
Returns
true; MetalLookAndFeel can be run on
any platform. |
void |
provideErrorFeedback(Component component)
Invoked when the user attempts an invalid operation,
such as pasting into an uneditable
JTextField
that has focus. |
static void |
setCurrentTheme(MetalTheme theme)
Set the theme used by
MetalLookAndFeel. |
createAudioAction, getAudioActionMap, initialize, loadSystemColors, playSound, uninitializegetDesktopPropertyValue, installBorder, installColors, installColorsAndFont, installProperty, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, toString, uninstallBorderpublic String getName()
"Metal".getName in class LookAndFeelpublic String getID()
"Metal".getID in class LookAndFeelpublic String getDescription()
"The Java(tm) Look and Feel".getDescription in class LookAndFeelpublic boolean isNativeLookAndFeel()
false; MetalLookAndFeel is not a native
look and feel.isNativeLookAndFeel in class LookAndFeelfalsepublic boolean isSupportedLookAndFeel()
true; MetalLookAndFeel can be run on
any platform.isSupportedLookAndFeel in class LookAndFeeltrueUIManager.setLookAndFeel(javax.swing.LookAndFeel)public boolean getSupportsWindowDecorations()
true; metal can provide Window
decorations.getSupportsWindowDecorations in class LookAndFeeltrueJDialog.setDefaultLookAndFeelDecorated(boolean),
JFrame.setDefaultLookAndFeelDecorated(boolean),
JRootPane.setWindowDecorationStyle(int)protected void initClassDefaults(UIDefaults table)
table with mappings from uiClassID to
the fully qualified name of the ui class. MetalLookAndFeel registers an entry for each of the classes in
the package javax.swing.plaf.metal that are named
MetalXXXUI. The string XXX is one of Swing's uiClassIDs. For
the uiClassIDs that do not have a class in metal, the
corresponding class in javax.swing.plaf.basic is
used. For example, metal does not have a class named "MetalColorChooserUI", as such, javax.swing.plaf.basic.BasicColorChooserUI is used.initClassDefaults in class BasicLookAndFeeltable - the UIDefaults instance the entries are
added toNullPointerException - if table is nullBasicLookAndFeel.initClassDefaults(javax.swing.UIDefaults)protected void initSystemColorDefaults(UIDefaults table)
table with system colors. The following values are
added to table:
| 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 current MetalTheme.initSystemColorDefaults in class BasicLookAndFeeltable - the UIDefaults object the values are added toNullPointerException - if table is nullSystemColor,
BasicLookAndFeel.getDefaults(),
BasicLookAndFeel.loadSystemColors(javax.swing.UIDefaults, java.lang.String[], boolean)protected void initComponentDefaults(UIDefaults table)
table with the defaults for metal.initComponentDefaults in class BasicLookAndFeeltable - the UIDefaults to add the values toNullPointerException - if table is nullprotected void createDefaultTheme()
MetalTheme is non-null. This is
a cover method for getCurrentTheme.getCurrentTheme()public UIDefaults getDefaults()
createDefaultTheme(), super.getDefaults() and
getCurrentTheme().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 after initialize has been invoked.
getDefaults in class BasicLookAndFeelcreateDefaultTheme(),
BasicLookAndFeel.getDefaults(),
MetalTheme.addCustomEntriesToTable(UIDefaults)public void provideErrorFeedback(Component component)
JTextField
that has focus. The default implementation beeps. Subclasses
that wish different behavior should override this and provide
the additional feedback.provideErrorFeedback in class LookAndFeelcomponent - the Component the error occurred in,
may be null
indicating the error condition is not directly
associated with a Componentpublic static void setCurrentTheme(MetalTheme theme)
MetalLookAndFeel.
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.
theme - the theme to useNullPointerException - if theme is nullgetCurrentTheme()public static MetalTheme getCurrentTheme()
MetalLookAndFeel.
If the current theme is null, the default theme is created.setCurrentTheme(javax.swing.plaf.metal.MetalTheme)public Icon getDisabledIcon(JComponent component, Icon icon)
Icon with a disabled appearance.
This method is used to generate a disabled Icon when
one has not been specified. For example, if you create a
JButton and only specify an Icon via
setIcon this method will be called to generate the
disabled Icon. If null is passed as icon
this method returns null.
Some look and feels might not render the disabled Icon, in which case they will ignore this.
getDisabledIcon in class LookAndFeelcomponent - JComponent that will display the Icon, may be nullicon - Icon to generate disable icon from.public Icon getDisabledSelectedIcon(JComponent component, Icon icon)
Icon for use by disabled
components that are also selected. This method is used to generate an
Icon for components that are in both the disabled and
selected states but do not have a specific Icon for this
state. For example, if you create a JButton and only
specify an Icon via setIcon this method
will be called to generate the disabled and selected
Icon. If null is passed as icon this method
returns null.
Some look and feels might not render the disabled and selected Icon, in which case they will ignore this.
getDisabledSelectedIcon in class LookAndFeelcomponent - JComponent that will display the Icon, may be nullicon - Icon to generate disabled and selected icon from.public static FontUIResource getControlTextFont()
getCurrentTheme().getControlTextColor().MetalThemepublic static FontUIResource getSystemTextFont()
getCurrentTheme().getSystemTextFont().MetalThemepublic static FontUIResource getUserTextFont()
getCurrentTheme().getUserTextFont().MetalThemepublic static FontUIResource getMenuTextFont()
getCurrentTheme().getMenuTextFont().MetalThemepublic static FontUIResource getWindowTitleFont()
getCurrentTheme().getWindowTitleFont().MetalThemepublic static FontUIResource getSubTextFont()
getCurrentTheme().getSubTextFont().MetalThemepublic static ColorUIResource getDesktopColor()
getCurrentTheme().getDesktopColor().MetalThemepublic static ColorUIResource getFocusColor()
getCurrentTheme().getFocusColor().MetalThemepublic static ColorUIResource getWhite()
getCurrentTheme().getWhite().MetalThemepublic static ColorUIResource getBlack()
getCurrentTheme().getBlack().MetalThemepublic static ColorUIResource getControl()
getCurrentTheme().getControl().MetalThemepublic static ColorUIResource getControlShadow()
getCurrentTheme().getControlShadow().MetalThemepublic static ColorUIResource getControlDarkShadow()
getCurrentTheme().getControlDarkShadow().MetalThemepublic static ColorUIResource getControlInfo()
getCurrentTheme().getControlInfo().MetalThemepublic static ColorUIResource getControlHighlight()
getCurrentTheme().getControlHighlight().MetalThemepublic static ColorUIResource getControlDisabled()
getCurrentTheme().getControlDisabled().MetalThemepublic static ColorUIResource getPrimaryControl()
getCurrentTheme().getPrimaryControl().MetalThemepublic static ColorUIResource getPrimaryControlShadow()
getCurrentTheme().getPrimaryControlShadow().MetalThemepublic static ColorUIResource getPrimaryControlDarkShadow()
getCurrentTheme().getPrimaryControlDarkShadow().MetalThemepublic static ColorUIResource getPrimaryControlInfo()
getCurrentTheme().getPrimaryControlInfo().MetalThemepublic static ColorUIResource getPrimaryControlHighlight()
getCurrentTheme().getPrimaryControlHighlight().MetalThemepublic static ColorUIResource getSystemTextColor()
getCurrentTheme().getSystemTextColor().MetalThemepublic static ColorUIResource getControlTextColor()
getCurrentTheme().getControlTextColor().MetalThemepublic static ColorUIResource getInactiveControlTextColor()
getCurrentTheme().getInactiveControlTextColor().MetalThemepublic static ColorUIResource getInactiveSystemTextColor()
getCurrentTheme().getInactiveSystemTextColor().MetalThemepublic static ColorUIResource getUserTextColor()
getCurrentTheme().getUserTextColor().MetalThemepublic static ColorUIResource getTextHighlightColor()
getCurrentTheme().getTextHighlightColor().MetalThemepublic static ColorUIResource getHighlightedTextColor()
getCurrentTheme().getHighlightedTextColor().MetalThemepublic static ColorUIResource getWindowBackground()
getCurrentTheme().getWindowBackground().MetalThemepublic static ColorUIResource getWindowTitleBackground()
getCurrentTheme().getWindowTitleBackground().MetalThemepublic static ColorUIResource getWindowTitleForeground()
getCurrentTheme().getWindowTitleForeground().MetalThemepublic static ColorUIResource getWindowTitleInactiveBackground()
getCurrentTheme().getWindowTitleInactiveBackground().MetalThemepublic static ColorUIResource getWindowTitleInactiveForeground()
getCurrentTheme().getWindowTitleInactiveForeground().MetalThemepublic static ColorUIResource getMenuBackground()
getCurrentTheme().getMenuBackground().MetalThemepublic static ColorUIResource getMenuForeground()
getCurrentTheme().getMenuForeground().MetalThemepublic static ColorUIResource getMenuSelectedBackground()
getCurrentTheme().getMenuSelectedBackground().MetalThemepublic static ColorUIResource getMenuSelectedForeground()
getCurrentTheme().getMenuSelectedForeground().MetalThemepublic static ColorUIResource getMenuDisabledForeground()
getCurrentTheme().getMenuDisabledForeground().MetalThemepublic static ColorUIResource getSeparatorBackground()
getCurrentTheme().getSeparatorBackground().MetalThemepublic static ColorUIResource getSeparatorForeground()
getCurrentTheme().getSeparatorForeground().MetalThemepublic static ColorUIResource getAcceleratorForeground()
getCurrentTheme().getAcceleratorForeground().MetalThemepublic static ColorUIResource getAcceleratorSelectedForeground()
getCurrentTheme().getAcceleratorSelectedForeground().MetalThemepublic LayoutStyle getLayoutStyle()
LayoutStyle implementing the Java look and feel
design guidelines as specified at
http://www.oracle.com/technetwork/java/hig-136467.html.getLayoutStyle in class LookAndFeelLayoutStyle.getInstance() Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2016, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.