FileDocCategorySizeDatePackage
DefaultMetalTheme.javaAPI DocJava SE 6 API13534Tue Jun 10 00:26:50 BST 2008javax.swing.plaf.metal

DefaultMetalTheme

public class DefaultMetalTheme extends MetalTheme
A concrete implementation of {@code MetalTheme} providing the original look of the Java Look and Feel, code-named "Steel". Refer to {@link MetalLookAndFeel#setCurrentTheme} for details on changing the default theme.

All colors returned by {@code DefaultMetalTheme} are completely opaque.

Font Style

{@code 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:
  • Set the system property swing.boldMetal to false. For example, java -Dswing.boldMetal=false MyApp.
  • Set the defaults property swing.boldMetal to Boolean.FALSE. For example: UIManager.put("swing.boldMetal", Boolean.FALSE);
The defaults property swing.boldMetal, if set, takes precendence 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 JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}.

see
MetalLookAndFeel
see
MetalLookAndFeel#setCurrentTheme
version
1.31 07/12/06
author
Steve Wilson

Fields 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".
private static final String[]
fontNames
Names of the fonts to use.
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.
private static final int[]
fontSizes
Sizes for the fonts.
private static final String[]
defaultNames
System property names used to look up fonts.
private static final ColorUIResource
primary1
private static final ColorUIResource
primary2
private static final ColorUIResource
primary3
private static final ColorUIResource
secondary1
private static final ColorUIResource
secondary2
private static final ColorUIResource
secondary3
private FontDelegate
fontDelegate
Constructors Summary
public DefaultMetalTheme()
Creates and returns an instance of {@code DefaultMetalTheme}.

        install();
    
Methods Summary
public javax.swing.plaf.FontUIResourcegetControlTextFont()
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.

return
the control text font

 
        return getFont(CONTROL_TEXT_FONT);
    
static java.lang.StringgetDefaultFontName(int key)
Returns the ideal font name for the font identified by key.


                    
        
        return fontNames[key];
    
static intgetDefaultFontSize(int key)
Returns the ideal font size for the font identified by key.

        return fontSizes[key];
    
static intgetDefaultFontStyle(int key)
Returns the ideal font style for the font identified by key.

        if (key != WINDOW_TITLE_FONT) {
            Object boldMetal = null;
            if (AppContext.getAppContext().get(
                    SwingUtilities2.LAF_STATE_KEY) != null) {
                // Only access the boldMetal key if a look and feel has
                // been loaded, otherwise we'll trigger loading the look
                // and feel.
                boldMetal = UIManager.get("swing.boldMetal");
            }
            if (boldMetal != null) {
                if (Boolean.FALSE.equals(boldMetal)) {
                    return Font.PLAIN;
                }
            }
            else if (PLAIN_FONTS) {
                return Font.PLAIN;
            }
        }
        return fontStyles[key];
    
static java.lang.StringgetDefaultPropertyName(int key)
Returns the default used to look up the specified font.

        return defaultNames[key];
    
private javax.swing.plaf.FontUIResourcegetFont(int key)

        return fontDelegate.getFont(key);
    
public javax.swing.plaf.FontUIResourcegetMenuTextFont()
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.

return
the menu text font

 
        return getFont(MENU_TEXT_FONT);
    
public java.lang.StringgetName()
Returns the name of this theme. This returns {@code "Steel"}.

return
the name of this theme.


                         
        return "Steel"; 
protected javax.swing.plaf.ColorUIResourcegetPrimary1()
Returns the primary 1 color. This returns a color with rgb values of 102, 102, and 153, respectively.

return
the primary 1 color

 return primary1; 
protected javax.swing.plaf.ColorUIResourcegetPrimary2()
Returns the primary 2 color. This returns a color with rgb values of 153, 153, 204, respectively.

return
the primary 2 color

 return primary2; 
protected javax.swing.plaf.ColorUIResourcegetPrimary3()
Returns the primary 3 color. This returns a color with rgb values 204, 204, 255, respectively.

return
the primary 3 color

 return primary3; 
protected javax.swing.plaf.ColorUIResourcegetSecondary1()
Returns the secondary 1 color. This returns a color with rgb values 102, 102, and 102, respectively.

return
the secondary 1 color

 return secondary1; 
protected javax.swing.plaf.ColorUIResourcegetSecondary2()
Returns the secondary 2 color. This returns a color with rgb values 153, 153, and 153, respectively.

return
the secondary 2 color

 return secondary2; 
protected javax.swing.plaf.ColorUIResourcegetSecondary3()
Returns the secondary 3 color. This returns a color with rgb values 204, 204, and 204, respectively.

return
the secondary 3 color

 return secondary3; 
public javax.swing.plaf.FontUIResourcegetSubTextFont()
Returns the sub-text font. This returns Dialog, 10pt, plain.

return
the sub-text font

 
        return getFont(SUB_TEXT_FONT);
    
public javax.swing.plaf.FontUIResourcegetSystemTextFont()
Returns the system text font. This returns Dialog, 12pt, plain.

return
the sytem text font

 
        return getFont(SYSTEM_TEXT_FONT);
    
public javax.swing.plaf.FontUIResourcegetUserTextFont()
Returns the user text font. This returns Dialog, 12pt, plain.

return
the user text font

 
        return getFont(USER_TEXT_FONT);
    
public javax.swing.plaf.FontUIResourcegetWindowTitleFont()
Returns the window title font. This returns Dialog, 12pt, bold.

return
the window title font

 
        return getFont(WINDOW_TITLE_FONT);
    
voidinstall()

        if (MetalLookAndFeel.isWindows() &&
                             MetalLookAndFeel.useSystemFonts()) {
            fontDelegate = new WindowsFontDelegate();
        }
        else {
            fontDelegate = new FontDelegate();
        }
    
booleanisSystemTheme()
Returns true if this is a theme provided by the core platform.

        return (getClass() == DefaultMetalTheme.class);