| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 |
getBlack() 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 |
getDisabledSelectedIcon(JComponent component, Icon 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 |
getID() 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 |
getName() 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 |
getWhite() 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 |
initClassDefaults(UIDefaults table) Populates with mappings from to the fully qualified name of the ui class. |
protected void |
initComponentDefaults(UIDefaults table) 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 |
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) 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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MetalLookAndFeel()
Method Detail |
---|
protected void createDefaultTheme()
public static ColorUIResource getAcceleratorForeground()
public static ColorUIResource getAcceleratorSelectedForeground()
public static ColorUIResource getBlack()
public static ColorUIResource getControl()
public static ColorUIResource getControlDarkShadow()
public static ColorUIResource getControlDisabled()
public static ColorUIResource getControlHighlight()
public static ColorUIResource getControlInfo()
public static ColorUIResource getControlShadow()
public static ColorUIResource getControlTextColor()
public static FontUIResource getControlTextFont()
public static MetalTheme getCurrentTheme()
MetalLookAndFeel
.
If the current theme is {@code null}, the default theme is created.
public UIDefaults getDefaults()
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.
getDefaults
in class BasicLookAndFeel
public String getDescription()
getDescription
in class LookAndFeel
public static ColorUIResource getDesktopColor()
public Icon getDisabledIcon(JComponent component, Icon icon)
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.
getDisabledIcon
in class LookAndFeel
component
- JComponent that will display the Icon, may be nullicon
- Icon to generate disable icon from.public Icon getDisabledSelectedIcon(JComponent component, Icon icon)
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.
getDisabledSelectedIcon
in class LookAndFeel
component
- JComponent that will display the Icon, may be nullicon
- Icon to generate disabled and selected icon from.public static ColorUIResource getFocusColor()
public static ColorUIResource getHighlightedTextColor()
public String getID()
getID
in class LookAndFeel
public static ColorUIResource getInactiveControlTextColor()
public static ColorUIResource getInactiveSystemTextColor()
public LayoutStyle getLayoutStyle()
getLayoutStyle
in class LookAndFeel
public static ColorUIResource getMenuBackground()
public static ColorUIResource getMenuDisabledForeground()
public static ColorUIResource getMenuForeground()
public static ColorUIResource getMenuSelectedBackground()
public static ColorUIResource getMenuSelectedForeground()
public static FontUIResource getMenuTextFont()
public String getName()
getName
in class LookAndFeel
public static ColorUIResource getPrimaryControl()
public static ColorUIResource getPrimaryControlDarkShadow()
public static ColorUIResource getPrimaryControlHighlight()
public static ColorUIResource getPrimaryControlInfo()
public static ColorUIResource getPrimaryControlShadow()
public static ColorUIResource getSeparatorBackground()
public static ColorUIResource getSeparatorForeground()
public static FontUIResource getSubTextFont()
public boolean getSupportsWindowDecorations()
getSupportsWindowDecorations
in class LookAndFeel
public static ColorUIResource getSystemTextColor()
public static FontUIResource getSystemTextFont()
public static ColorUIResource getTextHighlightColor()
public static ColorUIResource getUserTextColor()
public static FontUIResource getUserTextFont()
public static ColorUIResource getWhite()
public static ColorUIResource getWindowBackground()
public static ColorUIResource getWindowTitleBackground()
public static FontUIResource getWindowTitleFont()
public static ColorUIResource getWindowTitleForeground()
public static ColorUIResource getWindowTitleInactiveBackground()
public static ColorUIResource getWindowTitleInactiveForeground()
protected void initClassDefaults(UIDefaults table)
initClassDefaults
in class BasicLookAndFeel
table
- the {@code UIDefaults} instance the entries are
added toprotected void initComponentDefaults(UIDefaults table)
initComponentDefaults
in class BasicLookAndFeel
table
- the {@code UIDefaults} to add the values toprotected void initSystemColorDefaults(UIDefaults 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()} |
initSystemColorDefaults
in class BasicLookAndFeel
table
- the {@code UIDefaults} object the values are added topublic boolean isNativeLookAndFeel()
isNativeLookAndFeel
in class LookAndFeel
public boolean isSupportedLookAndFeel()
isSupportedLookAndFeel
in class LookAndFeel
public void provideErrorFeedback(Component component)
provideErrorFeedback
in class LookAndFeel
component
public static void setCurrentTheme(MetalTheme theme)
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.
theme
- the theme to use
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |