javax.swing.plaf.metal
Class MetalLookAndFeel

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

public class MetalLookAndFeel
extends BasicLookAndFeel

Implements the Java look and feel (codename: Metal).

For the keyboard keys defined for each component in this look and feel, see Component Keystroke Actions for the Java Look and Feel.

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 XMLEncoder.

Author:
Steve Wilson
See Also:
Serialized Form

Nested Class Summary
private static class MetalLookAndFeel.FontActiveValue
          FontActiveValue redirects to the appropriate metal theme method.
private static class MetalLookAndFeel.MetalLazyValue
          MetalLazyValue is a slimmed down version of ProxyLaxyValue.
 
Nested classes inherited from class javax.swing.plaf.basic.BasicLookAndFeel
 
Field Summary
private static sun.awt.AppContext cachedAppContext
           
private static boolean checkedSystemFontSettings
          Set to true first time we've checked swing.useSystemFontSettings.
private static boolean checkedWindows
          True if checked for windows yet.
private static MetalTheme currentTheme
           
private static boolean isOnlyOneContext
           
private static boolean isWindows
          True if running on Windows.
private static boolean METAL_LOOK_AND_FEEL_INITED
           
private static boolean useSystemFonts
          True indicates we should use system fonts, unless the developer has specified otherwise with Application.useSystemFontSettings.
 
Fields inherited from class javax.swing.plaf.basic.BasicLookAndFeel
 
Constructor Summary
MetalLookAndFeel()
           
 
Method Summary
protected  void createDefaultTheme()
           
static ColorUIResource getAcceleratorForeground()
           
static ColorUIResource getAcceleratorSelectedForeground()
           
static ColorUIResource getBlack()
           
static ColorUIResource getControl()
           
static ColorUIResource getControlDarkShadow()
           
static ColorUIResource getControlDisabled()
           
static ColorUIResource getControlHighlight()
           
static ColorUIResource getControlInfo()
           
static ColorUIResource getControlShadow()
           
static ColorUIResource getControlTextColor()
           
static FontUIResource getControlTextFont()
           
private static MetalTheme getCurrentTheme()
           
 UIDefaults getDefaults()
          This method is called once by UIManager.setLookAndFeel to create the look and feel specific defaults table.
 String getDescription()
          Return a one line description of this look and feel implementation, e.g.
static ColorUIResource getDesktopColor()
           
static ColorUIResource getFocusColor()
           
static ColorUIResource getHighlightedTextColor()
           
 String getID()
          Return a string that identifies this look and feel.
static ColorUIResource getInactiveControlTextColor()
           
static ColorUIResource getInactiveSystemTextColor()
           
static ColorUIResource getMenuBackground()
           
static ColorUIResource getMenuDisabledForeground()
           
static ColorUIResource getMenuForeground()
           
static ColorUIResource getMenuSelectedBackground()
           
static ColorUIResource getMenuSelectedForeground()
           
static FontUIResource getMenuTextFont()
           
 String getName()
          Return a short string that identifies this look and feel, e.g.
static ColorUIResource getPrimaryControl()
           
static ColorUIResource getPrimaryControlDarkShadow()
           
static ColorUIResource getPrimaryControlHighlight()
           
static ColorUIResource getPrimaryControlInfo()
           
static ColorUIResource getPrimaryControlShadow()
           
static ColorUIResource getSeparatorBackground()
           
static ColorUIResource getSeparatorForeground()
           
static FontUIResource getSubTextFont()
           
 boolean getSupportsWindowDecorations()
          Returns true if the LookAndFeel returned RootPaneUI instances support providing Window decorations in a JRootPane.
static ColorUIResource getSystemTextColor()
           
static FontUIResource getSystemTextFont()
           
static ColorUIResource getTextHighlightColor()
           
static ColorUIResource getUserTextColor()
           
static FontUIResource getUserTextFont()
           
static ColorUIResource getWhite()
           
static ColorUIResource getWindowBackground()
           
static ColorUIResource getWindowTitleBackground()
           
static FontUIResource getWindowTitleFont()
           
static ColorUIResource getWindowTitleForeground()
           
static ColorUIResource getWindowTitleInactiveBackground()
           
static ColorUIResource getWindowTitleInactiveForeground()
           
protected  void initClassDefaults(UIDefaults table)
          Creates the mapping from UI class IDs to ComponentUI classes, putting the ID-ComponentUI pairs in the passed-in defaults table.
protected  void initComponentDefaults(UIDefaults table)
           
private  void initResourceBundle(UIDefaults table)
          Initialize the defaults table with the name of the ResourceBundle used for getting localized defaults.
protected  void initSystemColorDefaults(UIDefaults table)
          Load the SystemColors into the defaults table.
 boolean isNativeLookAndFeel()
          If the underlying platform has a "native" look and feel, and this is an implementation of it, return true.
 boolean isSupportedLookAndFeel()
          Return true if the underlying platform supports and or permits this look and feel.
(package private) static boolean isWindows()
          Returns true if running on Windows.
 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)
           
private static boolean useHighContrastTheme()
          Returns true if the high contrast theme should be used as the default theme.
(package private) static boolean useSystemFonts()
          Returns true if system fonts should be used, this is only useful for windows.
 
Methods inherited from class javax.swing.plaf.basic.BasicLookAndFeel
createAudioAction, getAudioActionMap, loadSystemColors, playSound
 
Methods inherited from class javax.swing.LookAndFeel
getDesktopPropertyValue, initialize, installBorder, installColors, installColorsAndFont, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, toString, uninitialize, uninstallBorder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

METAL_LOOK_AND_FEEL_INITED

private static boolean METAL_LOOK_AND_FEEL_INITED

currentTheme

private static MetalTheme currentTheme

isOnlyOneContext

private static boolean isOnlyOneContext

cachedAppContext

private static sun.awt.AppContext cachedAppContext

checkedWindows

private static boolean checkedWindows
True if checked for windows yet.


isWindows

private static boolean isWindows
True if running on Windows.


checkedSystemFontSettings

private static boolean checkedSystemFontSettings
Set to true first time we've checked swing.useSystemFontSettings.


useSystemFonts

private static boolean useSystemFonts
True indicates we should use system fonts, unless the developer has specified otherwise with Application.useSystemFontSettings.

Constructor Detail

MetalLookAndFeel

public MetalLookAndFeel()
Method Detail

isWindows

static boolean isWindows()
Returns true if running on Windows.


useSystemFonts

static boolean useSystemFonts()
Returns true if system fonts should be used, this is only useful for windows.


useHighContrastTheme

private static boolean useHighContrastTheme()
Returns true if the high contrast theme should be used as the default theme.


getName

public String getName()
Description copied from class: LookAndFeel
Return a short string that identifies this look and feel, e.g. "CDE/Motif". This string should be appropriate for a menu item. Distinct look and feels should have different names, e.g. a subclass of MotifLookAndFeel that changes the way a few components are rendered should be called "CDE/Motif My Way"; something that would be useful to a user trying to select a L&F from a list of names.

Specified by:
getName in class LookAndFeel

getID

public String getID()
Description copied from class: LookAndFeel
Return a string that identifies this look and feel. This string will be used by applications/services that want to recognize well known look and feel implementations. Presently the well known names are "Motif", "Windows", "Mac", "Metal". Note that a LookAndFeel derived from a well known superclass that doesn't make any fundamental changes to the look or feel shouldn't override this method.

Specified by:
getID in class LookAndFeel

getDescription

public String getDescription()
Description copied from class: LookAndFeel
Return a one line description of this look and feel implementation, e.g. "The CDE/Motif Look and Feel". This string is intended for the user, e.g. in the title of a window or in a ToolTip message.

Specified by:
getDescription in class LookAndFeel

isNativeLookAndFeel

public boolean isNativeLookAndFeel()
Description copied from class: LookAndFeel
If the underlying platform has a "native" look and feel, and this is an implementation of it, return true. For example a CDE/Motif look and implementation would return true when the underlying platform was Solaris.

Specified by:
isNativeLookAndFeel in class LookAndFeel

isSupportedLookAndFeel

public boolean isSupportedLookAndFeel()
Description copied from class: LookAndFeel
Return true if the underlying platform supports and or permits this look and feel. This method returns false if the look and feel depends on special resources or legal agreements that aren't defined for the current platform.

Specified by:
isSupportedLookAndFeel in class LookAndFeel
See Also:
UIManager.setLookAndFeel(javax.swing.LookAndFeel)

getSupportsWindowDecorations

public boolean getSupportsWindowDecorations()
Returns true if the LookAndFeel returned RootPaneUI instances support providing Window decorations in a JRootPane.

This implementation returns true, since it does support providing these border and window title pane decorations.

Overrides:
getSupportsWindowDecorations in class LookAndFeel
Returns:
True if the RootPaneUI instances created support client side decorations
Since:
1.4
See Also:
JDialog.setDefaultLookAndFeelDecorated(boolean), JFrame.setDefaultLookAndFeelDecorated(boolean), JRootPane.setWindowDecorationStyle(int)

initClassDefaults

protected void initClassDefaults(UIDefaults table)
Creates the mapping from UI class IDs to ComponentUI classes, putting the ID-ComponentUI pairs in the passed-in defaults table. Each JComponent class specifies its own UI class ID string. For example, JButton has the UI class ID "ButtonUI", which this method maps to "javax.swing.plaf.metal.MetalButtonUI".

Overrides:
initClassDefaults in class BasicLookAndFeel
See Also:
BasicLookAndFeel.getDefaults(), JComponent.getUIClassID()

initSystemColorDefaults

protected void initSystemColorDefaults(UIDefaults table)
Load the SystemColors into the defaults table. The keys for SystemColor defaults are the same as the names of the public fields in SystemColor.

Overrides:
initSystemColorDefaults in class BasicLookAndFeel

initResourceBundle

private void initResourceBundle(UIDefaults table)
Initialize the defaults table with the name of the ResourceBundle used for getting localized defaults.


initComponentDefaults

protected void initComponentDefaults(UIDefaults table)
Overrides:
initComponentDefaults in class BasicLookAndFeel

createDefaultTheme

protected void createDefaultTheme()

getDefaults

public UIDefaults getDefaults()
Description copied from class: LookAndFeel
This method is called once by UIManager.setLookAndFeel to create the look and feel specific defaults table. Other applications, for example an application builder, may also call this method.

Overrides:
getDefaults in class BasicLookAndFeel

provideErrorFeedback

public void provideErrorFeedback(Component component)

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.

Overrides:
provideErrorFeedback in class LookAndFeel
Parameters:
component - Component the error occured in, may be null indicating the error condition is not directly associated with a Component.
See Also:
LookAndFeel.provideErrorFeedback(java.awt.Component)

setCurrentTheme

public static void setCurrentTheme(MetalTheme theme)

getCurrentTheme

private static MetalTheme getCurrentTheme()

getControlTextFont

public static FontUIResource getControlTextFont()

getSystemTextFont

public static FontUIResource getSystemTextFont()

getUserTextFont

public static FontUIResource getUserTextFont()

getMenuTextFont

public static FontUIResource getMenuTextFont()

getWindowTitleFont

public static FontUIResource getWindowTitleFont()

getSubTextFont

public static FontUIResource getSubTextFont()

getDesktopColor

public static ColorUIResource getDesktopColor()

getFocusColor

public static ColorUIResource getFocusColor()

getWhite

public static ColorUIResource getWhite()

getBlack

public static ColorUIResource getBlack()

getControl

public static ColorUIResource getControl()

getControlShadow

public static ColorUIResource getControlShadow()

getControlDarkShadow

public static ColorUIResource getControlDarkShadow()

getControlInfo

public static ColorUIResource getControlInfo()

getControlHighlight

public static ColorUIResource getControlHighlight()

getControlDisabled

public static ColorUIResource getControlDisabled()

getPrimaryControl

public static ColorUIResource getPrimaryControl()

getPrimaryControlShadow

public static ColorUIResource getPrimaryControlShadow()

getPrimaryControlDarkShadow

public static ColorUIResource getPrimaryControlDarkShadow()

getPrimaryControlInfo

public static ColorUIResource getPrimaryControlInfo()

getPrimaryControlHighlight

public static ColorUIResource getPrimaryControlHighlight()

getSystemTextColor

public static ColorUIResource getSystemTextColor()

getControlTextColor

public static ColorUIResource getControlTextColor()

getInactiveControlTextColor

public static ColorUIResource getInactiveControlTextColor()

getInactiveSystemTextColor

public static ColorUIResource getInactiveSystemTextColor()

getUserTextColor

public static ColorUIResource getUserTextColor()

getTextHighlightColor

public static ColorUIResource getTextHighlightColor()

getHighlightedTextColor

public static ColorUIResource getHighlightedTextColor()

getWindowBackground

public static ColorUIResource getWindowBackground()

getWindowTitleBackground

public static ColorUIResource getWindowTitleBackground()

getWindowTitleForeground

public static ColorUIResource getWindowTitleForeground()

getWindowTitleInactiveBackground

public static ColorUIResource getWindowTitleInactiveBackground()

getWindowTitleInactiveForeground

public static ColorUIResource getWindowTitleInactiveForeground()

getMenuBackground

public static ColorUIResource getMenuBackground()

getMenuForeground

public static ColorUIResource getMenuForeground()

getMenuSelectedBackground

public static ColorUIResource getMenuSelectedBackground()

getMenuSelectedForeground

public static ColorUIResource getMenuSelectedForeground()

getMenuDisabledForeground

public static ColorUIResource getMenuDisabledForeground()

getSeparatorBackground

public static ColorUIResource getSeparatorBackground()

getSeparatorForeground

public static ColorUIResource getSeparatorForeground()

getAcceleratorForeground

public static ColorUIResource getAcceleratorForeground()

getAcceleratorSelectedForeground

public static ColorUIResource getAcceleratorSelectedForeground()