This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing.plaf.metal
class MetalLookAndFeel

java.lang.Object extended by javax.swing.LookAndFeel extended by javax.swing.plaf.basic.BasicLookAndFeel extended by javax.swing.plaf.metal.MetalLookAndFeel
All Implemented Interfaces:
Serializable

public class MetalLookAndFeel
extends BasicLookAndFeel

The Java Look and Feel, otherwise known as Metal.

Each of the {@code ComponentUI}s provided by {@code MetalLookAndFeel} derives its behavior from the defaults table. Unless otherwise noted each of the {@code ComponentUI} implementations in this package document the set of defaults they use. Unless otherwise noted the defaults are installed at the time {@code installUI} is invoked, and follow the recommendations outlined in {@code LookAndFeel} for installing defaults.

{@code MetalLookAndFeel} derives it's color palette and fonts from {@code MetalTheme}. The default theme is {@code OceanTheme}. The theme can be changed using the {@code setCurrentTheme} method, refer to it for details on changing the theme. Prior to 1.5 the default theme was {@code DefaultMetalTheme}. The system property {@code "swing.metalTheme"} can be set to {@code "steel"} to indicate the default should be {@code 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 JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}.


Constructor Summary

          
 
Method Summary
protected void

          Ensures the current is .
static ColorUIResource

          Returns the accelerator foreground color of the current theme.
static ColorUIResource

          Returns the accelerator selected foreground color of the current theme.
static ColorUIResource

          Returns the black color of the current theme.
static ColorUIResource

          Returns the control color of the current theme.
static ColorUIResource

          Returns the control dark shadow color of the current theme.
static ColorUIResource

          Returns the control disabled color of the current theme.
static ColorUIResource

          Returns the control highlight color of the current theme.
static ColorUIResource

          Returns the control info color of the current theme.
static ColorUIResource

          Returns the control shadow color of the current theme.
static ColorUIResource

          Returns the control text color of the current theme.
static FontUIResource

          Returns the control text font of the current theme.
static MetalTheme

          Return the theme currently being used by MetalLookAndFeel.
 UIDefaults

          Returns the look and feel defaults.
 String

          Returns a short description of this look and feel.
static ColorUIResource

          Returns the desktop color of the current theme.
 Icon
getDisabledIcon(JComponent component, Icon icon)

          Returns an Icon with a disabled appearance.
 Icon

          Returns an Icon for use by disabled components that are also selected.
static ColorUIResource

          Returns the focus color of the current theme.
static ColorUIResource

          Returns the highlighted text color of the current theme.
 String

          Returns an identifier for this look and feel.
static ColorUIResource

          Returns the inactive control text color of the current theme.
static ColorUIResource

          Returns the inactive system text color of the current theme.
 LayoutStyle

          Returns a implementing the Java look and feel design guidelines as specified at http://java.sun.com/products/jlf/ed2/book/HIG.Visual2.html.
static ColorUIResource

          Returns the menu background color of the current theme.
static ColorUIResource

          Returns the menu disabled foreground color of the current theme.
static ColorUIResource

          Returns the menu foreground color of the current theme.
static ColorUIResource

          Returns the menu selected background color of the current theme.
static ColorUIResource

          Returns the menu selected foreground color of the current theme.
static FontUIResource

          Returns the menu text font of the current theme.
 String

          Returns the name of this look and feel.
static ColorUIResource

          Returns the primary control color of the current theme.
static ColorUIResource

          Returns the primary control dark shadow color of the current theme.
static ColorUIResource

          Returns the primary control highlight color of the current theme.
static ColorUIResource

          Returns the primary control info color of the current theme.
static ColorUIResource

          Returns the primary control shadow color of the current theme.
static ColorUIResource

          Returns the separator background color of the current theme.
static ColorUIResource

          Returns the separator foreground color of the current theme.
static FontUIResource

          Returns the sub-text font of the current theme.
 boolean

          Returns ; metal can provide decorations.
static ColorUIResource

          Returns the system text color of the current theme.
static FontUIResource

          Returns the sytem text font of the current theme.
static ColorUIResource

          Returns the text highlight color of the current theme.
static ColorUIResource

          Returns the user text color of the current theme.
static FontUIResource

          Returns the user text font of the current theme.
static ColorUIResource

          Returns the white color of the current theme.
static ColorUIResource

          Returns the window background color of the current theme.
static ColorUIResource

          Returns the window title background color of the current theme.
static FontUIResource

          Returns the window title font of the current theme.
static ColorUIResource

          Returns the window title foreground color of the current theme.
static ColorUIResource

          Returns the window title inactive background color of the current theme.
static ColorUIResource

          Returns the window title inactive foreground color of the current theme.
protected void

          Populates with mappings from to the fully qualified name of the ui class.
protected void

          Populates with the defaults for metal.
protected void

          Populates with system colors.
 boolean

          Returns ; is not a native look and feel.
 boolean

          Returns ; can be run on any platform.
 void

          Invoked when the user attempts an invalid operation, such as pasting into an uneditable JTextField that has focus.
static void

          Set the theme used by MetalLookAndFeel.
 
Methods inherited from class javax.swing.plaf.basic.BasicLookAndFeel
createAudioAction, getAudioActionMap, getDefaults, initClassDefaults, initComponentDefaults, initialize, initSystemColorDefaults, loadSystemColors, playSound, uninitialize
 
Methods inherited from class javax.swing.LookAndFeel
getDefaults, getDescription, getDesktopPropertyValue, getDisabledIcon, getDisabledSelectedIcon, getID, getLayoutStyle, getName, getSupportsWindowDecorations, initialize, installBorder, installColors, installColorsAndFont, installProperty, isNativeLookAndFeel, isSupportedLookAndFeel, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, provideErrorFeedback, toString, uninitialize, uninstallBorder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetalLookAndFeel

public MetalLookAndFeel()
Method Detail

createDefaultTheme

protected void createDefaultTheme()
Ensures the current {@code MetalTheme} is {@code non-null}. This is a cover method for {@code getCurrentTheme}.


getAcceleratorForeground

public static ColorUIResource getAcceleratorForeground()
Returns the accelerator foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getAcceleratorForeground()}.

Returns:
the separator accelerator foreground color

getAcceleratorSelectedForeground

public static ColorUIResource getAcceleratorSelectedForeground()
Returns the accelerator selected foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getAcceleratorSelectedForeground()}.

Returns:
the accelerator selected foreground color

getBlack

public static ColorUIResource getBlack()
Returns the black color of the current theme. This is a cover method for {@code getCurrentTheme().getBlack()}.

Returns:
the black color

getControl

public static ColorUIResource getControl()
Returns the control color of the current theme. This is a cover method for {@code getCurrentTheme().getControl()}.

Returns:
the control color

getControlDarkShadow

public static ColorUIResource getControlDarkShadow()
Returns the control dark shadow color of the current theme. This is a cover method for {@code getCurrentTheme().getControlDarkShadow()}.

Returns:
the control dark shadow color

getControlDisabled

public static ColorUIResource getControlDisabled()
Returns the control disabled color of the current theme. This is a cover method for {@code getCurrentTheme().getControlDisabled()}.

Returns:
the control disabled color

getControlHighlight

public static ColorUIResource getControlHighlight()
Returns the control highlight color of the current theme. This is a cover method for {@code getCurrentTheme().getControlHighlight()}.

Returns:
the control highlight color

getControlInfo

public static ColorUIResource getControlInfo()
Returns the control info color of the current theme. This is a cover method for {@code getCurrentTheme().getControlInfo()}.

Returns:
the control info color

getControlShadow

public static ColorUIResource getControlShadow()
Returns the control shadow color of the current theme. This is a cover method for {@code getCurrentTheme().getControlShadow()}.

Returns:
the control shadow color

getControlTextColor

public static ColorUIResource getControlTextColor()
Returns the control text color of the current theme. This is a cover method for {@code getCurrentTheme().getControlTextColor()}.

Returns:
the control text color

getControlTextFont

public static FontUIResource getControlTextFont()
Returns the control text font of the current theme. This is a cover method for {@code getCurrentTheme().getControlTextColor()}.

Returns:
the control text font

getCurrentTheme

public static MetalTheme getCurrentTheme()
Return the theme currently being used by MetalLookAndFeel. If the current theme is {@code null}, the default theme is created.

Returns:
the current theme

getDefaults

public UIDefaults getDefaults()
Returns the look and feel defaults. This invokes, in order, {@code createDefaultTheme()}, {@code super.getDefaults()} and {@code getCurrentTheme().addCustomEntriesToTable(table)}.

While this method is public, it should only be invoked by the {@code UIManager} when the look and feel is set as the current look and feel and after {@code initialize} has been invoked.

Overrides:
getDefaults in class BasicLookAndFeel
Returns:
the look and feel defaults

getDescription

public String getDescription()
Returns a short description of this look and feel. This returns {@code "The Java(tm) Look and Feel"}.

Overrides:
getDescription in class LookAndFeel
Returns:
a short description for the look and feel

getDesktopColor

public static ColorUIResource getDesktopColor()
Returns the desktop color of the current theme. This is a cover method for {@code getCurrentTheme().getDesktopColor()}.

Returns:
the desktop color

getDisabledIcon

public Icon getDisabledIcon(JComponent component,
                            Icon icon)
Returns an 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.

Overrides:
getDisabledIcon in class LookAndFeel
Parameters:
component - JComponent that will display the Icon, may be null
icon - Icon to generate disable icon from.
Returns:
Disabled icon, or null if a suitable Icon can not be generated.

getDisabledSelectedIcon

public Icon getDisabledSelectedIcon(JComponent component,
                                    Icon icon)
Returns an 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.

Overrides:
getDisabledSelectedIcon in class LookAndFeel
Parameters:
component - JComponent that will display the Icon, may be null
icon - Icon to generate disabled and selected icon from.
Returns:
Disabled and Selected icon, or null if a suitable Icon can not be generated.

getFocusColor

public static ColorUIResource getFocusColor()
Returns the focus color of the current theme. This is a cover method for {@code getCurrentTheme().getFocusColor()}.

Returns:
the focus color

getHighlightedTextColor

public static ColorUIResource getHighlightedTextColor()
Returns the highlighted text color of the current theme. This is a cover method for {@code getCurrentTheme().getHighlightedTextColor()}.

Returns:
the highlighted text color

getID

public String getID()
Returns an identifier for this look and feel. This returns {@code "Metal"}.

Overrides:
getID in class LookAndFeel
Returns:
the identifier of this look and feel

getInactiveControlTextColor

public static ColorUIResource getInactiveControlTextColor()
Returns the inactive control text color of the current theme. This is a cover method for {@code getCurrentTheme().getInactiveControlTextColor()}.

Returns:
the inactive control text color

getInactiveSystemTextColor

public static ColorUIResource getInactiveSystemTextColor()
Returns the inactive system text color of the current theme. This is a cover method for {@code getCurrentTheme().getInactiveSystemTextColor()}.

Returns:
the inactive system text color

getLayoutStyle

public LayoutStyle getLayoutStyle()
Returns a {@code LayoutStyle} implementing the Java look and feel design guidelines as specified at http://java.sun.com/products/jlf/ed2/book/HIG.Visual2.html.

Overrides:
getLayoutStyle in class LookAndFeel
Returns:
LayoutStyle implementing the Java look and feel design guidelines

getMenuBackground

public static ColorUIResource getMenuBackground()
Returns the menu background color of the current theme. This is a cover method for {@code getCurrentTheme().getMenuBackground()}.

Returns:
the menu background color

getMenuDisabledForeground

public static ColorUIResource getMenuDisabledForeground()
Returns the menu disabled foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getMenuDisabledForeground()}.

Returns:
the menu disabled foreground color

getMenuForeground

public static ColorUIResource getMenuForeground()
Returns the menu foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getMenuForeground()}.

Returns:
the menu foreground color

getMenuSelectedBackground

public static ColorUIResource getMenuSelectedBackground()
Returns the menu selected background color of the current theme. This is a cover method for {@code getCurrentTheme().getMenuSelectedBackground()}.

Returns:
the menu selected background color

getMenuSelectedForeground

public static ColorUIResource getMenuSelectedForeground()
Returns the menu selected foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getMenuSelectedForeground()}.

Returns:
the menu selected foreground color

getMenuTextFont

public static FontUIResource getMenuTextFont()
Returns the menu text font of the current theme. This is a cover method for {@code getCurrentTheme().getMenuTextFont()}.

Returns:
the menu text font

getName

public String getName()
Returns the name of this look and feel. This returns {@code "Metal"}.

Overrides:
getName in class LookAndFeel
Returns:
the name of this look and feel

getPrimaryControl

public static ColorUIResource getPrimaryControl()
Returns the primary control color of the current theme. This is a cover method for {@code getCurrentTheme().getPrimaryControl()}.

Returns:
the primary control color

getPrimaryControlDarkShadow

public static ColorUIResource getPrimaryControlDarkShadow()
Returns the primary control dark shadow color of the current theme. This is a cover method for {@code getCurrentTheme().getPrimaryControlDarkShadow()}.

Returns:
the primary control dark shadow color

getPrimaryControlHighlight

public static ColorUIResource getPrimaryControlHighlight()
Returns the primary control highlight color of the current theme. This is a cover method for {@code getCurrentTheme().getPrimaryControlHighlight()}.

Returns:
the primary control highlight color

getPrimaryControlInfo

public static ColorUIResource getPrimaryControlInfo()
Returns the primary control info color of the current theme. This is a cover method for {@code getCurrentTheme().getPrimaryControlInfo()}.

Returns:
the primary control info color

getPrimaryControlShadow

public static ColorUIResource getPrimaryControlShadow()
Returns the primary control shadow color of the current theme. This is a cover method for {@code getCurrentTheme().getPrimaryControlShadow()}.

Returns:
the primary control shadow color

getSeparatorBackground

public static ColorUIResource getSeparatorBackground()
Returns the separator background color of the current theme. This is a cover method for {@code getCurrentTheme().getSeparatorBackground()}.

Returns:
the separator background color

getSeparatorForeground

public static ColorUIResource getSeparatorForeground()
Returns the separator foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getSeparatorForeground()}.

Returns:
the separator foreground color

getSubTextFont

public static FontUIResource getSubTextFont()
Returns the sub-text font of the current theme. This is a cover method for {@code getCurrentTheme().getSubTextFont()}.

Returns:
the sub-text font

getSupportsWindowDecorations

public boolean getSupportsWindowDecorations()
Returns {@code true}; metal can provide {@code Window} decorations.

Overrides:
getSupportsWindowDecorations in class LookAndFeel
Returns:
{@code true}

getSystemTextColor

public static ColorUIResource getSystemTextColor()
Returns the system text color of the current theme. This is a cover method for {@code getCurrentTheme().getSystemTextColor()}.

Returns:
the system text color

getSystemTextFont

public static FontUIResource getSystemTextFont()
Returns the sytem text font of the current theme. This is a cover method for {@code getCurrentTheme().getSystemTextFont()}.

Returns:
the system text font

getTextHighlightColor

public static ColorUIResource getTextHighlightColor()
Returns the text highlight color of the current theme. This is a cover method for {@code getCurrentTheme().getTextHighlightColor()}.

Returns:
the text highlight color

getUserTextColor

public static ColorUIResource getUserTextColor()
Returns the user text color of the current theme. This is a cover method for {@code getCurrentTheme().getUserTextColor()}.

Returns:
the user text color

getUserTextFont

public static FontUIResource getUserTextFont()
Returns the user text font of the current theme. This is a cover method for {@code getCurrentTheme().getUserTextFont()}.

Returns:
the user text font

getWhite

public static ColorUIResource getWhite()
Returns the white color of the current theme. This is a cover method for {@code getCurrentTheme().getWhite()}.

Returns:
the white color

getWindowBackground

public static ColorUIResource getWindowBackground()
Returns the window background color of the current theme. This is a cover method for {@code getCurrentTheme().getWindowBackground()}.

Returns:
the window background color

getWindowTitleBackground

public static ColorUIResource getWindowTitleBackground()
Returns the window title background color of the current theme. This is a cover method for {@code getCurrentTheme().getWindowTitleBackground()}.

Returns:
the window title background color

getWindowTitleFont

public static FontUIResource getWindowTitleFont()
Returns the window title font of the current theme. This is a cover method for {@code getCurrentTheme().getWindowTitleFont()}.

Returns:
the window title font

getWindowTitleForeground

public static ColorUIResource getWindowTitleForeground()
Returns the window title foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getWindowTitleForeground()}.

Returns:
the window title foreground color

getWindowTitleInactiveBackground

public static ColorUIResource getWindowTitleInactiveBackground()
Returns the window title inactive background color of the current theme. This is a cover method for {@code getCurrentTheme().getWindowTitleInactiveBackground()}.

Returns:
the window title inactive background color

getWindowTitleInactiveForeground

public static ColorUIResource getWindowTitleInactiveForeground()
Returns the window title inactive foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getWindowTitleInactiveForeground()}.

Returns:
the window title inactive foreground color

initClassDefaults

protected void initClassDefaults(UIDefaults table)
Populates {@code table} with mappings from {@code uiClassID} to the fully qualified name of the ui class. {@code MetalLookAndFeel} registers an entry for each of the classes in the package {@code javax.swing.plaf.metal} that are named MetalXXXUI. The string {@code XXX} is one of Swing's uiClassIDs. For the {@code uiClassIDs} that do not have a class in metal, the corresponding class in {@code javax.swing.plaf.basic} is used. For example, metal does not have a class named {@code "MetalColorChooserUI"}, as such, {@code javax.swing.plaf.basic.BasicColorChooserUI} is used.

Overrides:
initClassDefaults in class BasicLookAndFeel
Parameters:
table - the {@code UIDefaults} instance the entries are added to

initComponentDefaults

protected void initComponentDefaults(UIDefaults table)
Populates {@code table} with the defaults for metal.

Overrides:
initComponentDefaults in class BasicLookAndFeel
Parameters:
table - the {@code UIDefaults} to add the values to

initSystemColorDefaults

protected void initSystemColorDefaults(UIDefaults table)
Populates {@code table} with system colors. The following values are added to {@code table}:
Key Value
"desktop" {@code theme.getDesktopColor()}
"activeCaption" {@code theme.getWindowTitleBackground()}
"activeCaptionText" {@code theme.getWindowTitleForeground()}
"activeCaptionBorder" {@code theme.getPrimaryControlShadow()}
"inactiveCaption" {@code theme.getWindowTitleInactiveBackground()}
"inactiveCaptionText" {@code theme.getWindowTitleInactiveForeground()}
"inactiveCaptionBorder" {@code theme.getControlShadow()}
"window" {@code theme.getWindowBackground()}
"windowBorder" {@code theme.getControl()}
"windowText" {@code theme.getUserTextColor()}
"menu" {@code theme.getMenuBackground()}
"menuText" {@code theme.getMenuForeground()}
"text" {@code theme.getWindowBackground()}
"textText" {@code theme.getUserTextColor()}
"textHighlight" {@code theme.getTextHighlightColor()}
"textHighlightText" {@code theme.getHighlightedTextColor()}
"textInactiveText" {@code theme.getInactiveSystemTextColor()}
"control" {@code theme.getControl()}
"controlText" {@code theme.getControlTextColor()}
"controlHighlight" {@code theme.getControlHighlight()}
"controlLtHighlight" {@code theme.getControlHighlight()}
"controlShadow" {@code theme.getControlShadow()}
"controlDkShadow" {@code theme.getControlDarkShadow()}
"scrollbar" {@code theme.getControl()}
"info" {@code theme.getPrimaryControl()}
"infoText" {@code theme.getPrimaryControlInfo()}
The value {@code theme} corresponds to the current {@code MetalTheme}.

Overrides:
initSystemColorDefaults in class BasicLookAndFeel
Parameters:
table - the {@code UIDefaults} object the values are added to

isNativeLookAndFeel

public boolean isNativeLookAndFeel()
Returns {@code false}; {@code MetalLookAndFeel} is not a native look and feel.

Overrides:
isNativeLookAndFeel in class LookAndFeel
Returns:
{@code false}

isSupportedLookAndFeel

public boolean isSupportedLookAndFeel()
Returns {@code true}; {@code MetalLookAndFeel} can be run on any platform.

Overrides:
isSupportedLookAndFeel in class LookAndFeel
Returns:
{@code true}

provideErrorFeedback

public void provideErrorFeedback(Component component)
{@inheritDoc}

Overrides:
provideErrorFeedback in class LookAndFeel
Parameters:
component

setCurrentTheme

public static void setCurrentTheme(MetalTheme theme)
Set the theme used by MetalLookAndFeel.

After the theme is set, {@code 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


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.