APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.plaf.metal

public Class DefaultMetalTheme

extends MetalTheme
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.metal.MetalHighContrastTheme, javax.swing.plaf.metal.OceanTheme
Imports
javax.swing.plaf.*, javax.swing.*, java.awt.*, sun.swing.SwingAccessor, .SwingUtilities2

A concrete implementation of MetalTheme providing the original look of the Java Look and Feel, code-named "Steel". Refer to MetalLookAndFeel#setCurrentTheme for details on changing the default theme.

All colors returned by DefaultMetalTheme are completely opaque.

Font Style

DefaultMetalTheme 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: The defaults property swing.boldMetal, if set, takes precedence over the system property of the same name. After setting this defaults property you need to re-install MetalLookAndFeel, as well as update the UI of any previously created widgets. Otherwise the results are undefined. The following illustrates how to do this:
  // turn off bold fonts
  UIManager.put("swing.boldMetal", Boolean.FALSE);

  // 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);

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

Author
Steve Wilson
See Also
MetalLookAndFeel, MetalLookAndFeel#setCurrentTheme

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
DefaultMetalTheme.FontDelegate

FontDelegates add an extra level of indirection to obtaining fonts.

private static class
DefaultMetalTheme.WindowsFontDelegate

The WindowsFontDelegate uses DesktopProperties to obtain fonts.

Field Summary

Modifier and TypeField and Description
private static final String[]
defaultNames

System property names used to look up fonts.

private DefaultMetalTheme.FontDelegate
private static final String[]
fontNames

Names of the fonts to use.

private static final int[]
fontSizes

Sizes for the fonts.

private static final int[]
fontStyles

Styles for the fonts.

private static final boolean
PLAIN_FONTS

Whether or not fonts should be plain.

private static final ColorUIResource
private static final ColorUIResource
private static final ColorUIResource
private static final ColorUIResource
private static final ColorUIResource
private static final ColorUIResource
Inherited from javax.swing.plaf.metal.MetalTheme:
CONTROL_TEXT_FONTMENU_TEXT_FONTSUB_TEXT_FONTSYSTEM_TEXT_FONTUSER_TEXT_FONTwhiteWINDOW_TITLE_FONT

Constructor Summary

AccessConstructor and Description
public
DefaultMetalTheme()

Creates and returns an instance of DefaultMetalTheme.

Method Summary

Modifier and TypeMethod and Description
public FontUIResource

Returns:

the control text font
getControlTextFont
()

Implements abstract javax.swing.plaf.metal.MetalTheme.getControlTextFont.

Returns the control text font.

pack-priv static String
getDefaultFontName(int key)

Returns the ideal font name for the font identified by key.

pack-priv static int
getDefaultFontSize(int key)

Returns the ideal font size for the font identified by key.

pack-priv static int
getDefaultFontStyle(int key)

Returns the ideal font style for the font identified by key.

pack-priv static String
getDefaultPropertyName(int key)

Returns the default used to look up the specified font.

private FontUIResource
getFont(int key)

public FontUIResource

Returns:

the menu text font
getMenuTextFont
()

Implements abstract javax.swing.plaf.metal.MetalTheme.getMenuTextFont.

Returns the menu text font.

public String

Returns:

the name of this theme.
getName
()

Implements abstract javax.swing.plaf.metal.MetalTheme.getName.

Returns the name of this theme.

protected ColorUIResource

Returns:

the primary 1 color
getPrimary1
()

Implements abstract javax.swing.plaf.metal.MetalTheme.getPrimary1.

Returns the primary 1 color.

protected ColorUIResource

Returns:

the primary 2 color
getPrimary2
()

Implements abstract javax.swing.plaf.metal.MetalTheme.getPrimary2.

Returns the primary 2 color.

protected ColorUIResource

Returns:

the primary 3 color
getPrimary3
()

Implements abstract javax.swing.plaf.metal.MetalTheme.getPrimary3.

Returns the primary 3 color.

protected ColorUIResource

Returns:

the secondary 1 color
getSecondary1
()

Implements abstract javax.swing.plaf.metal.MetalTheme.getSecondary1.

Returns the secondary 1 color.

protected ColorUIResource

Returns:

the secondary 2 color
getSecondary2
()

Implements abstract javax.swing.plaf.metal.MetalTheme.getSecondary2.

Returns the secondary 2 color.

protected ColorUIResource

Returns:

the secondary 3 color
getSecondary3
()

Implements abstract javax.swing.plaf.metal.MetalTheme.getSecondary3.

Returns the secondary 3 color.

public FontUIResource

Returns:

the sub-text font
getSubTextFont
()

Implements abstract javax.swing.plaf.metal.MetalTheme.getSubTextFont.

Returns the sub-text font.

public FontUIResource

Returns:

the system text font
getSystemTextFont
()

Implements abstract javax.swing.plaf.metal.MetalTheme.getSystemTextFont.

Returns the system text font.

public FontUIResource

Returns:

the user text font
getUserTextFont
()

Implements abstract javax.swing.plaf.metal.MetalTheme.getUserTextFont.

Returns the user text font.

public FontUIResource

Returns:

the window title font
getWindowTitleFont
()

Implements abstract javax.swing.plaf.metal.MetalTheme.getWindowTitleFont.

Returns the window title font.

pack-priv void
install()

Overrides javax.swing.plaf.metal.MetalTheme.install.

This is invoked when a MetalLookAndFeel is installed and about to start using this theme.

pack-priv boolean
isSystemTheme()

Overrides javax.swing.plaf.metal.MetalTheme.isSystemTheme.

Returns true if this is a theme provided by the core platform.

Inherited from javax.swing.plaf.metal.MetalTheme:
addCustomEntriesToTablegetAcceleratorForegroundgetAcceleratorSelectedForegroundgetBlackgetControlgetControlDarkShadowgetControlDisabledgetControlHighlightgetControlInfogetControlShadowgetControlTextColorgetDesktopColorgetFocusColorgetHighlightedTextColorgetInactiveControlTextColorgetInactiveSystemTextColorgetMenuBackgroundgetMenuDisabledForegroundgetMenuForegroundgetMenuSelectedBackgroundgetMenuSelectedForegroundgetPrimaryControlgetPrimaryControlDarkShadowgetPrimaryControlHighlightgetPrimaryControlInfogetPrimaryControlShadowgetSeparatorBackgroundgetSeparatorForegroundgetSystemTextColorgetTextHighlightColorgetUserTextColorgetWhitegetWindowBackgroundgetWindowTitleBackgroundgetWindowTitleForegroundgetWindowTitleInactiveBackgroundgetWindowTitleInactiveForeground

Field Detail

defaultNamesback to summary
private static final String[] defaultNames

System property names used to look up fonts.

fontDelegateback to summary
private DefaultMetalTheme.FontDelegate fontDelegate
fontNamesback to summary
private static final String[] fontNames

Names of the fonts to use.

fontSizesback to summary
private static final int[] fontSizes

Sizes for the fonts.

fontStylesback to summary
private static final int[] fontStyles

Styles for the fonts. This is ignored if the defaults property swing.boldMetal is false, or PLAIN_FONTS is true.

PLAIN_FONTSback to summary
private static final boolean PLAIN_FONTS

Whether or not fonts should be plain. This is only used if the defaults property 'swing.boldMetal' == "false".

primary1back to summary
private static final ColorUIResource primary1
primary2back to summary
private static final ColorUIResource primary2
primary3back to summary
private static final ColorUIResource primary3
secondary1back to summary
private static final ColorUIResource secondary1
secondary2back to summary
private static final ColorUIResource secondary2
secondary3back to summary
private static final ColorUIResource secondary3

Constructor Detail

DefaultMetalThemeback to summary
public DefaultMetalTheme()

Creates and returns an instance of DefaultMetalTheme.

Method Detail

getControlTextFontback to summary
public FontUIResource getControlTextFont()

Implements abstract javax.swing.plaf.metal.MetalTheme.getControlTextFont.

Returns the control text font. This returns Dialog, 12pt. If plain fonts have been enabled as described in font style, the font style is plain. Otherwise the font style is bold.

Returns:FontUIResource

the control text font

getDefaultFontNameback to summary
pack-priv static String getDefaultFontName(int key)

Returns the ideal font name for the font identified by key.

getDefaultFontSizeback to summary
pack-priv static int getDefaultFontSize(int key)

Returns the ideal font size for the font identified by key.

getDefaultFontStyleback to summary
pack-priv static int getDefaultFontStyle(int key)

Returns the ideal font style for the font identified by key.

getDefaultPropertyNameback to summary
pack-priv static String getDefaultPropertyName(int key)

Returns the default used to look up the specified font.

getFontback to summary
private FontUIResource getFont(int key)
getMenuTextFontback to summary
public FontUIResource getMenuTextFont()

Implements abstract javax.swing.plaf.metal.MetalTheme.getMenuTextFont.

Returns the menu text font. This returns Dialog, 12pt. If plain fonts have been enabled as described in font style, the font style is plain. Otherwise the font style is bold.

Returns:FontUIResource

the menu text font

getNameback to summary
public String getName()

Implements abstract javax.swing.plaf.metal.MetalTheme.getName.

Returns the name of this theme. This returns "Steel".

Returns:String

the name of this theme.

getPrimary1back to summary
protected ColorUIResource getPrimary1()

Implements abstract javax.swing.plaf.metal.MetalTheme.getPrimary1.

Returns the primary 1 color. This returns a color with rgb values of 102, 102, and 153, respectively.

Returns:ColorUIResource

the primary 1 color

getPrimary2back to summary
protected ColorUIResource getPrimary2()

Implements abstract javax.swing.plaf.metal.MetalTheme.getPrimary2.

Returns the primary 2 color. This returns a color with rgb values of 153, 153, 204, respectively.

Returns:ColorUIResource

the primary 2 color

getPrimary3back to summary
protected ColorUIResource getPrimary3()

Implements abstract javax.swing.plaf.metal.MetalTheme.getPrimary3.

Returns the primary 3 color. This returns a color with rgb values 204, 204, 255, respectively.

Returns:ColorUIResource

the primary 3 color

getSecondary1back to summary
protected ColorUIResource getSecondary1()

Implements abstract javax.swing.plaf.metal.MetalTheme.getSecondary1.

Returns the secondary 1 color. This returns a color with rgb values 102, 102, and 102, respectively.

Returns:ColorUIResource

the secondary 1 color

getSecondary2back to summary
protected ColorUIResource getSecondary2()

Implements abstract javax.swing.plaf.metal.MetalTheme.getSecondary2.

Returns the secondary 2 color. This returns a color with rgb values 153, 153, and 153, respectively.

Returns:ColorUIResource

the secondary 2 color

getSecondary3back to summary
protected ColorUIResource getSecondary3()

Implements abstract javax.swing.plaf.metal.MetalTheme.getSecondary3.

Returns the secondary 3 color. This returns a color with rgb values 204, 204, and 204, respectively.

Returns:ColorUIResource

the secondary 3 color

getSubTextFontback to summary
public FontUIResource getSubTextFont()

Implements abstract javax.swing.plaf.metal.MetalTheme.getSubTextFont.

Returns the sub-text font. This returns Dialog, 10pt, plain.

Returns:FontUIResource

the sub-text font

getSystemTextFontback to summary
public FontUIResource getSystemTextFont()

Implements abstract javax.swing.plaf.metal.MetalTheme.getSystemTextFont.

Returns the system text font. This returns Dialog, 12pt, plain.

Returns:FontUIResource

the system text font

getUserTextFontback to summary
public FontUIResource getUserTextFont()

Implements abstract javax.swing.plaf.metal.MetalTheme.getUserTextFont.

Returns the user text font. This returns Dialog, 12pt, plain.

Returns:FontUIResource

the user text font

getWindowTitleFontback to summary
public FontUIResource getWindowTitleFont()

Implements abstract javax.swing.plaf.metal.MetalTheme.getWindowTitleFont.

Returns the window title font. This returns Dialog, 12pt, bold.

Returns:FontUIResource

the window title font

installback to summary
pack-priv void install()

Overrides javax.swing.plaf.metal.MetalTheme.install.

Doc from javax.swing.plaf.metal.MetalTheme.install.

This is invoked when a MetalLookAndFeel is installed and about to start using this theme. When we can add API this should be nuked in favor of DefaultMetalTheme overriding addCustomEntriesToTable.

isSystemThemeback to summary
pack-priv boolean isSystemTheme()

Overrides javax.swing.plaf.metal.MetalTheme.isSystemTheme.

Returns true if this is a theme provided by the core platform.

javax.swing.plaf.metal back to summary

private Class DefaultMetalTheme.FontDelegate

extends Object
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.metal.DefaultMetalTheme.WindowsFontDelegate

FontDelegates add an extra level of indirection to obtaining fonts.

Field Summary

Modifier and TypeField and Description
private static int[]
pack-priv FontUIResource[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public FontUIResource
getFont(int type)

protected Font
getFontForType(final int key)

This is the same as invoking Font.getFont(key)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultMappingback to summary
private static int[] defaultMapping
fontsback to summary
pack-priv FontUIResource[] fonts

Constructor Detail

FontDelegateback to summary
public FontDelegate()

Method Detail

getFontback to summary
public FontUIResource getFont(int type)
getFontForTypeback to summary
protected Font getFontForType(final int key)

This is the same as invoking Font.getFont(key)

javax.swing.plaf.metal back to summary

private Class DefaultMetalTheme.WindowsFontDelegate

extends FontDelegate
Class Inheritance

The WindowsFontDelegate uses DesktopProperties to obtain fonts.

Field Summary

Modifier and TypeField and Description
private boolean[]
private MetalFontDesktopProperty[]
Inherited from javax.swing.plaf.metal.DefaultMetalTheme.FontDelegate:
fonts

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public FontUIResource
Inherited from javax.swing.plaf.metal.DefaultMetalTheme.FontDelegate:
getFontForType

Field Detail

checkedback to summary
private boolean[] checked
propsback to summary
private MetalFontDesktopProperty[] props

Constructor Detail

WindowsFontDelegateback to summary
public WindowsFontDelegate()

Method Detail

getFontback to summary
public FontUIResource getFont(int type)

Overrides javax.swing.plaf.metal.DefaultMetalTheme.FontDelegate.getFont.