Home » openjdk-7 » javax » swing » plaf » metal » [javadoc | source]
javax.swing.plaf.metal
public class: MetalLookAndFeel [javadoc | source]
java.lang.Object
   javax.swing.LookAndFeel
      javax.swing.plaf.basic.BasicLookAndFeel
         javax.swing.plaf.metal.MetalLookAndFeel

All Implemented Interfaces:
    java$io$Serializable

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

Nested Class Summary:
static class  MetalLookAndFeel.AATextListener   
Field Summary
static  ReferenceQueue<LookAndFeel> queue     
Fields inherited from javax.swing.plaf.basic.BasicLookAndFeel:
needsEventHelper,  invocator
Method from javax.swing.plaf.metal.MetalLookAndFeel Summary:
createDefaultTheme,   flushUnreferenced,   getAcceleratorForeground,   getAcceleratorSelectedForeground,   getBlack,   getControl,   getControlDarkShadow,   getControlDisabled,   getControlHighlight,   getControlInfo,   getControlShadow,   getControlTextColor,   getControlTextFont,   getCurrentTheme,   getDefaults,   getDescription,   getDesktopColor,   getDisabledIcon,   getDisabledSelectedIcon,   getFocusColor,   getHighlightedTextColor,   getID,   getInactiveControlTextColor,   getInactiveSystemTextColor,   getLayoutStyle,   getMenuBackground,   getMenuDisabledForeground,   getMenuForeground,   getMenuSelectedBackground,   getMenuSelectedForeground,   getMenuTextFont,   getName,   getPrimaryControl,   getPrimaryControlDarkShadow,   getPrimaryControlHighlight,   getPrimaryControlInfo,   getPrimaryControlShadow,   getSeparatorBackground,   getSeparatorForeground,   getSubTextFont,   getSupportsWindowDecorations,   getSystemTextColor,   getSystemTextFont,   getTextHighlightColor,   getUserTextColor,   getUserTextFont,   getWhite,   getWindowBackground,   getWindowTitleBackground,   getWindowTitleFont,   getWindowTitleForeground,   getWindowTitleInactiveBackground,   getWindowTitleInactiveForeground,   initClassDefaults,   initComponentDefaults,   initSystemColorDefaults,   isNativeLookAndFeel,   isSupportedLookAndFeel,   isWindows,   provideErrorFeedback,   setCurrentTheme,   useSystemFonts,   usingOcean
Methods from javax.swing.plaf.basic.BasicLookAndFeel:
createAudioAction,   getAudioActionMap,   getDefaults,   getUIOfType,   initClassDefaults,   initComponentDefaults,   initSystemColorDefaults,   initialize,   installAWTEventListener,   installAudioActionMap,   loadSystemColors,   playSound,   playSound,   uninitialize
Methods from 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 from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.plaf.metal.MetalLookAndFeel Detail:
 protected  void createDefaultTheme() 
    Ensures the current {@code MetalTheme} is {@code non-null}. This is a cover method for {@code getCurrentTheme}.
 static  void flushUnreferenced() 
 public static ColorUIResource getAcceleratorForeground() 
    Returns the accelerator foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getAcceleratorForeground()}.
 public static ColorUIResource getAcceleratorSelectedForeground() 
    Returns the accelerator selected foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getAcceleratorSelectedForeground()}.
 public static ColorUIResource getBlack() 
    Returns the black color of the current theme. This is a cover method for {@code getCurrentTheme().getBlack()}.
 public static ColorUIResource getControl() 
    Returns the control color of the current theme. This is a cover method for {@code getCurrentTheme().getControl()}.
 public static ColorUIResource getControlDarkShadow() 
    Returns the control dark shadow color of the current theme. This is a cover method for {@code getCurrentTheme().getControlDarkShadow()}.
 public static ColorUIResource getControlDisabled() 
    Returns the control disabled color of the current theme. This is a cover method for {@code getCurrentTheme().getControlDisabled()}.
 public static ColorUIResource getControlHighlight() 
    Returns the control highlight color of the current theme. This is a cover method for {@code getCurrentTheme().getControlHighlight()}.
 public static ColorUIResource getControlInfo() 
    Returns the control info color of the current theme. This is a cover method for {@code getCurrentTheme().getControlInfo()}.
 public static ColorUIResource getControlShadow() 
    Returns the control shadow color of the current theme. This is a cover method for {@code getCurrentTheme().getControlShadow()}.
 public static ColorUIResource getControlTextColor() 
    Returns the control text color of the current theme. This is a cover method for {@code getCurrentTheme().getControlTextColor()}.
 public static FontUIResource getControlTextFont() 
    Returns the control text font of the current theme. This is a cover method for {@code getCurrentTheme().getControlTextColor()}.
 public static MetalTheme getCurrentTheme() 
    Return the theme currently being used by MetalLookAndFeel. If the current theme is {@code null}, the default theme is created.
 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.

 public String getDescription() 
    Returns a short description of this look and feel. This returns {@code "The Java(tm) Look and Feel"}.
 public static ColorUIResource getDesktopColor() 
    Returns the desktop color of the current theme. This is a cover method for {@code getCurrentTheme().getDesktopColor()}.
 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.

 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.

 public static ColorUIResource getFocusColor() 
    Returns the focus color of the current theme. This is a cover method for {@code getCurrentTheme().getFocusColor()}.
 public static ColorUIResource getHighlightedTextColor() 
    Returns the highlighted text color of the current theme. This is a cover method for {@code getCurrentTheme().getHighlightedTextColor()}.
 public String getID() 
    Returns an identifier for this look and feel. This returns {@code "Metal"}.
 public static ColorUIResource getInactiveControlTextColor() 
    Returns the inactive control text color of the current theme. This is a cover method for {@code getCurrentTheme().getInactiveControlTextColor()}.
 public static ColorUIResource getInactiveSystemTextColor() 
    Returns the inactive system text color of the current theme. This is a cover method for {@code getCurrentTheme().getInactiveSystemTextColor()}.
 public LayoutStyle getLayoutStyle() 
 public static ColorUIResource getMenuBackground() 
    Returns the menu background color of the current theme. This is a cover method for {@code getCurrentTheme().getMenuBackground()}.
 public static ColorUIResource getMenuDisabledForeground() 
    Returns the menu disabled foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getMenuDisabledForeground()}.
 public static ColorUIResource getMenuForeground() 
    Returns the menu foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getMenuForeground()}.
 public static ColorUIResource getMenuSelectedBackground() 
    Returns the menu selected background color of the current theme. This is a cover method for {@code getCurrentTheme().getMenuSelectedBackground()}.
 public static ColorUIResource getMenuSelectedForeground() 
    Returns the menu selected foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getMenuSelectedForeground()}.
 public static FontUIResource getMenuTextFont() 
    Returns the menu text font of the current theme. This is a cover method for {@code getCurrentTheme().getMenuTextFont()}.
 public String getName() 
    Returns the name of this look and feel. This returns {@code "Metal"}.
 public static ColorUIResource getPrimaryControl() 
    Returns the primary control color of the current theme. This is a cover method for {@code getCurrentTheme().getPrimaryControl()}.
 public static ColorUIResource getPrimaryControlDarkShadow() 
    Returns the primary control dark shadow color of the current theme. This is a cover method for {@code getCurrentTheme().getPrimaryControlDarkShadow()}.
 public static ColorUIResource getPrimaryControlHighlight() 
    Returns the primary control highlight color of the current theme. This is a cover method for {@code getCurrentTheme().getPrimaryControlHighlight()}.
 public static ColorUIResource getPrimaryControlInfo() 
    Returns the primary control info color of the current theme. This is a cover method for {@code getCurrentTheme().getPrimaryControlInfo()}.
 public static ColorUIResource getPrimaryControlShadow() 
    Returns the primary control shadow color of the current theme. This is a cover method for {@code getCurrentTheme().getPrimaryControlShadow()}.
 public static ColorUIResource getSeparatorBackground() 
    Returns the separator background color of the current theme. This is a cover method for {@code getCurrentTheme().getSeparatorBackground()}.
 public static ColorUIResource getSeparatorForeground() 
    Returns the separator foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getSeparatorForeground()}.
 public static FontUIResource getSubTextFont() 
    Returns the sub-text font of the current theme. This is a cover method for {@code getCurrentTheme().getSubTextFont()}.
 public boolean getSupportsWindowDecorations() 
    Returns {@code true}; metal can provide {@code Window} decorations.
 public static ColorUIResource getSystemTextColor() 
    Returns the system text color of the current theme. This is a cover method for {@code getCurrentTheme().getSystemTextColor()}.
 public static FontUIResource getSystemTextFont() 
    Returns the sytem text font of the current theme. This is a cover method for {@code getCurrentTheme().getSystemTextFont()}.
 public static ColorUIResource getTextHighlightColor() 
    Returns the text highlight color of the current theme. This is a cover method for {@code getCurrentTheme().getTextHighlightColor()}.
 public static ColorUIResource getUserTextColor() 
    Returns the user text color of the current theme. This is a cover method for {@code getCurrentTheme().getUserTextColor()}.
 public static FontUIResource getUserTextFont() 
    Returns the user text font of the current theme. This is a cover method for {@code getCurrentTheme().getUserTextFont()}.
 public static ColorUIResource getWhite() 
    Returns the white color of the current theme. This is a cover method for {@code getCurrentTheme().getWhite()}.
 public static ColorUIResource getWindowBackground() 
    Returns the window background color of the current theme. This is a cover method for {@code getCurrentTheme().getWindowBackground()}.
 public static ColorUIResource getWindowTitleBackground() 
    Returns the window title background color of the current theme. This is a cover method for {@code getCurrentTheme().getWindowTitleBackground()}.
 public static FontUIResource getWindowTitleFont() 
    Returns the window title font of the current theme. This is a cover method for {@code getCurrentTheme().getWindowTitleFont()}.
 public static ColorUIResource getWindowTitleForeground() 
    Returns the window title foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getWindowTitleForeground()}.
 public static ColorUIResource getWindowTitleInactiveBackground() 
    Returns the window title inactive background color of the current theme. This is a cover method for {@code getCurrentTheme().getWindowTitleInactiveBackground()}.
 public static ColorUIResource getWindowTitleInactiveForeground() 
    Returns the window title inactive foreground color of the current theme. This is a cover method for {@code getCurrentTheme().getWindowTitleInactiveForeground()}.
 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.
 protected  void initComponentDefaults(UIDefaults table) 
    Populates {@code table} with the defaults for metal.
 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}.
 public boolean isNativeLookAndFeel() 
    Returns {@code false}; {@code MetalLookAndFeel} is not a native look and feel.
 public boolean isSupportedLookAndFeel() 
    Returns {@code true}; {@code MetalLookAndFeel} can be run on any platform.
 static boolean isWindows() 
    Returns true if running on Windows.
 public  void provideErrorFeedback(Component component) 
    {@inheritDoc}
 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.
 static boolean useSystemFonts() 
    Returns true if system fonts should be used, this is only useful for windows.
 static boolean usingOcean() 
    Returns true if we're using the Ocean Theme.