java.lang.Object javax.swing.LookAndFeel javax.swing.plaf.basic.BasicLookAndFeel javax.swing.plaf.metal.MetalLookAndFeel
public class MetalLookAndFeel
The Java Look and Feel, otherwise known as Metal.
Implements the Java look and feel (codename: Metal).
By default metal uses bold fonts for many controls. To make all controls (with the exception of the internal frame title bars and client decorated frame title bars) use plain fonts you can do either of the following:
// turn off bold fonts UIManager.put("swing.boldMetal", Boolean.FALSE); // re-install the Metal Look and Feel UIManager.setLookAndFeel(new MetalLookAndFeel()); // only needed to update existing widgets SwingUtilities.updateComponentTreeUI(rootComponent);
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
TM
has been added to the java.beans package. Please see
XMLEncoder
.
|
|
---|---|
|
|
---|
|
|
---|
|
|
---|
|
|
---|
publicMetalLookAndFeel()
|
---|
publicStringgetName()
publicStringgetID()
publicStringgetDescription()
public booleanisNativeLookAndFeel()
public booleanisSupportedLookAndFeel()
public booleangetSupportsWindowDecorations()
This implementation returns true, since it does support providing these border and window title pane decorations.
protected voidinitClassDefaults(UIDefaultstable)
protected voidinitSystemColorDefaults(UIDefaultstable)
protected voidinitComponentDefaults(UIDefaultstable)
protected voidcreateDefaultTheme()
publicUIDefaultsgetDefaults()
public voidprovideErrorFeedback(Componentcomponent)
Invoked when the user attempts an invalid operation, such as pasting into an uneditable JTextField that has focus.
If the user has enabled visual error indication on the desktop, this method will flash the caption bar of the active window. The user can also set the property awt.visualbell=true to achieve the same results.
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.
public static voidsetCurrentTheme(MetalThemetheme)
// turn off bold fonts MetalLookAndFeel.setCurrentTheme(theme); // re-install the Metal Look and Feel UIManager.setLookAndFeel(new MetalLookAndFeel()); // only needed to update existing widgets SwingUtilities.updateComponentTreeUI(rootComponent);
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.
public staticMetalThemegetCurrentTheme()
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 TM has been added to the java.beans package. Please see XMLEncoder
publicIcongetDisabledIcon(JComponentcomponent,Iconicon)
Some look and feels might not render the disabled Icon, in which case they will ignore this.
publicIcongetDisabledSelectedIcon(JComponentcomponent,Iconicon)
Some look and feels might not render the disabled and selected Icon, in which case they will ignore this.
public staticFontUIResourcegetControlTextFont()
public staticFontUIResourcegetSystemTextFont()
public staticFontUIResourcegetUserTextFont()
public staticFontUIResourcegetMenuTextFont()
public staticFontUIResourcegetWindowTitleFont()
public staticFontUIResourcegetSubTextFont()
public staticColorUIResourcegetDesktopColor()
public staticColorUIResourcegetFocusColor()
public staticColorUIResourcegetWhite()
public staticColorUIResourcegetBlack()
public staticColorUIResourcegetControl()
public staticColorUIResourcegetControlShadow()
public staticColorUIResourcegetControlDarkShadow()
public staticColorUIResourcegetControlInfo()
public staticColorUIResourcegetControlHighlight()
public staticColorUIResourcegetControlDisabled()
public staticColorUIResourcegetPrimaryControl()
public staticColorUIResourcegetPrimaryControlShadow()
public staticColorUIResourcegetPrimaryControlDarkShadow()
public staticColorUIResourcegetPrimaryControlInfo()
public staticColorUIResourcegetPrimaryControlHighlight()
public staticColorUIResourcegetSystemTextColor()
public staticColorUIResourcegetControlTextColor()
public staticColorUIResourcegetInactiveControlTextColor()
public staticColorUIResourcegetInactiveSystemTextColor()
public staticColorUIResourcegetUserTextColor()
public staticColorUIResourcegetTextHighlightColor()
public staticColorUIResourcegetHighlightedTextColor()
public staticColorUIResourcegetWindowBackground()
public staticColorUIResourcegetWindowTitleBackground()
public staticColorUIResourcegetWindowTitleForeground()
public staticColorUIResourcegetWindowTitleInactiveBackground()
public staticColorUIResourcegetWindowTitleInactiveForeground()
public staticColorUIResourcegetMenuBackground()
public staticColorUIResourcegetMenuForeground()
public staticColorUIResourcegetMenuSelectedBackground()
public staticColorUIResourcegetMenuSelectedForeground()
public staticColorUIResourcegetMenuDisabledForeground()
public staticColorUIResourcegetSeparatorBackground()
public staticColorUIResourcegetSeparatorForeground()
public staticColorUIResourcegetAcceleratorForeground()
public staticColorUIResourcegetAcceleratorSelectedForeground()
publicLayoutStylegetLayoutStyle()
You generally don't use the LayoutStyle from the look and feel, instead use the LayoutStyle method getInstance.
Constructor Summary | |
---|---|
MetalLookAndFeel
()
|
Method Summary | |
---|---|
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
Returns an Icon with a disabled appearance. |
Icon |
getDisabledSelectedIcon
(
JComponent
component,
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://java.sun.com/products/jlf/ed2/book/HIG.Visual2.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 sytem 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
Populates table with mappings from uiClassID to the fully qualified name of the ui class. |
protected void |
initComponentDefaults
(
UIDefaults
Populates table with the defaults for metal. |
protected void |
initSystemColorDefaults
(
UIDefaults
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
Invoked when the user attempts an invalid operation, such as pasting into an uneditable JTextField that has focus. |
static void |
setCurrentTheme
(
MetalTheme
Set the theme used by MetalLookAndFeel. |
Methods inherited from class javax.swing.plaf.basic. BasicLookAndFeel |
---|
createAudioAction , getAudioActionMap , initialize , loadSystemColors , playSound , uninitialize |
Methods inherited from class javax.swing. LookAndFeel |
---|
getDesktopPropertyValue , installBorder , installColors , installColorsAndFont , installProperty , loadKeyBindings , makeComponentInputMap , makeIcon , makeInputMap , makeKeyBindings , toString , uninstallBorder |
Methods inherited from class java.lang. Object |
---|
clone , equals , finalize , getClass , hashCode , notify , notifyAll , wait , wait , wait |
Constructor Detail |
---|
public MetalLookAndFeel ()
Method Detail |
---|
public StringgetName ()
public StringgetID ()
public StringgetDescription ()
public boolean isNativeLookAndFeel ()
public boolean isSupportedLookAndFeel ()
public boolean getSupportsWindowDecorations ()
protected void initClassDefaults ( UIDefaults table)
protected void initSystemColorDefaults ( UIDefaults table)
protected void initComponentDefaults ( UIDefaults table)
protected void createDefaultTheme ()
public UIDefaultsgetDefaults ()
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.
public void provideErrorFeedback ( Component component)
public static void setCurrentTheme ( MetalTheme theme)
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.
public static MetalThemegetCurrentTheme ()
public IcongetDisabledIcon ( JComponent component, Icon icon)
Some look and feels might not render the disabled Icon, in which case they will ignore this.
public IcongetDisabledSelectedIcon ( JComponent component, Icon icon)
Some look and feels might not render the disabled and selected Icon, in which case they will ignore this.
public static FontUIResourcegetControlTextFont ()
public static FontUIResourcegetSystemTextFont ()
public static FontUIResourcegetUserTextFont ()
public static FontUIResourcegetMenuTextFont ()
public static FontUIResourcegetWindowTitleFont ()
public static FontUIResourcegetSubTextFont ()
public static ColorUIResourcegetDesktopColor ()
public static ColorUIResourcegetFocusColor ()
public static ColorUIResourcegetWhite ()
public static ColorUIResourcegetBlack ()
public static ColorUIResourcegetControl ()
public static ColorUIResourcegetControlShadow ()
public static ColorUIResourcegetControlDarkShadow ()
public static ColorUIResourcegetControlInfo ()
public static ColorUIResourcegetControlHighlight ()
public static ColorUIResourcegetControlDisabled ()
public static ColorUIResourcegetPrimaryControl ()
public static ColorUIResourcegetPrimaryControlShadow ()
public static ColorUIResourcegetPrimaryControlDarkShadow ()
public static ColorUIResourcegetPrimaryControlInfo ()
public static ColorUIResourcegetPrimaryControlHighlight ()
public static ColorUIResourcegetSystemTextColor ()
public static ColorUIResourcegetControlTextColor ()
public static ColorUIResourcegetInactiveControlTextColor ()
public static ColorUIResourcegetInactiveSystemTextColor ()
public static ColorUIResourcegetUserTextColor ()
public static ColorUIResourcegetTextHighlightColor ()
public static ColorUIResourcegetHighlightedTextColor ()
public static ColorUIResourcegetWindowBackground ()
public static ColorUIResourcegetWindowTitleBackground ()
public static ColorUIResourcegetWindowTitleForeground ()
public static ColorUIResourcegetWindowTitleInactiveBackground ()
public static ColorUIResourcegetWindowTitleInactiveForeground ()
public static ColorUIResourcegetMenuBackground ()
public static ColorUIResourcegetMenuForeground ()
public static ColorUIResourcegetMenuSelectedBackground ()
public static ColorUIResourcegetMenuSelectedForeground ()
public static ColorUIResourcegetMenuDisabledForeground ()
public static ColorUIResourcegetSeparatorBackground ()
public static ColorUIResourcegetSeparatorForeground ()
public static ColorUIResourcegetAcceleratorForeground ()
public static ColorUIResourcegetAcceleratorSelectedForeground ()
public LayoutStylegetLayoutStyle ()