|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.LookAndFeel
javax.swing.plaf.basic.BasicLookAndFeel
javax.swing.plaf.metal.MetalLookAndFeel
public class MetalLookAndFeel
A custom look and feel that is designed to look similar across different operating systems. To install this look and feel, add the following code (or something similar) near the start of your application:
try { UIManager.setLookAndFeel(new MetalLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); }
Constructor Summary | |
---|---|
MetalLookAndFeel()
Creates a new instance of the Metal look and feel. |
Method Summary | |
---|---|
protected void |
createDefaultTheme()
Sets the current theme to a new instance of DefaultMetalTheme . |
static ColorUIResource |
getAcceleratorForeground()
Returns the accelerator foreground color from the installed theme. |
static ColorUIResource |
getAcceleratorSelectedForeground()
Returns the accelerator selected foreground color from the installed theme. |
static ColorUIResource |
getBlack()
Returns the color black from the installed theme. |
static ColorUIResource |
getControl()
Returns the control color from the installed theme. |
static ColorUIResource |
getControlDarkShadow()
Returns the color used for dark shadows on controls, from the installed theme. |
static ColorUIResource |
getControlDisabled()
Returns the color used for disabled controls, from the installed theme. |
static ColorUIResource |
getControlHighlight()
Returns the color used to draw highlights for controls, from the installed theme. |
static ColorUIResource |
getControlInfo()
Returns the color used to display control info, from the installed theme. |
static ColorUIResource |
getControlShadow()
Returns the color used to draw shadows for controls, from the installed theme. |
static ColorUIResource |
getControlTextColor()
Returns the color used for text on controls, from the installed theme. |
static FontUIResource |
getControlTextFont()
Returns the font used for text on controls, from the installed theme. |
static MetalTheme |
getCurrentTheme()
Returns the current theme for the Metal look and feel. |
UIDefaults |
getDefaults()
Creates and returns a new instance of the default resources for this look and feel. |
String |
getDescription()
Returns a string describing the look and feel. |
static ColorUIResource |
getDesktopColor()
Returns the color used for the desktop background, from the installed theme. |
static ColorUIResource |
getFocusColor()
Returns the color used to draw focus highlights, from the installed theme. |
static ColorUIResource |
getHighlightedTextColor()
Returns the color used to draw highlighted text, from the installed theme. |
String |
getID()
Returns the look and feel identifier. |
static ColorUIResource |
getInactiveControlTextColor()
Returns the color used to draw text on inactive controls, from the installed theme. |
static ColorUIResource |
getInactiveSystemTextColor()
Returns the color used to draw inactive system text, from the installed theme. |
static ColorUIResource |
getMenuBackground()
Returns the background color for menu items, from the installed theme. |
static ColorUIResource |
getMenuDisabledForeground()
Returns the foreground color for disabled menu items, from the installed theme. |
static ColorUIResource |
getMenuForeground()
Returns the foreground color for menu items, from the installed theme. |
static ColorUIResource |
getMenuSelectedBackground()
Returns the background color for selected menu items, from the installed theme. |
static ColorUIResource |
getMenuSelectedForeground()
Returns the foreground color for selected menu items, from the installed theme. |
static FontUIResource |
getMenuTextFont()
Returns the font used for text in menus, from the installed theme. |
String |
getName()
Returns the look and feel name. |
static ColorUIResource |
getPrimaryControl()
Returns the primary color for controls, from the installed theme. |
static ColorUIResource |
getPrimaryControlDarkShadow()
Returns the primary color for the dark shadow on controls, from the installed theme. |
static ColorUIResource |
getPrimaryControlHighlight()
Returns the primary color for the highlight on controls, from the installed theme. |
static ColorUIResource |
getPrimaryControlInfo()
Returns the primary color for the information on controls, from the installed theme. |
static ColorUIResource |
getPrimaryControlShadow()
Returns the primary color for the shadow on controls, from the installed theme. |
static ColorUIResource |
getSeparatorBackground()
Returns the background color for separators, from the installed theme. |
static ColorUIResource |
getSeparatorForeground()
Returns the foreground color for separators, from the installed theme. |
static FontUIResource |
getSubTextFont()
Returns the font used for sub text, from the installed theme. |
boolean |
getSupportsWindowDecorations()
Returns true because the Metal look
and feel supports window decorations for toplevel
containers. |
static ColorUIResource |
getSystemTextColor()
Returns the color used for system text, from the installed theme. |
static FontUIResource |
getSystemTextFont()
Returns the font used for system text, from the installed theme. |
static ColorUIResource |
getTextHighlightColor()
Returns the color used to highlight text, from the installed theme. |
static ColorUIResource |
getUserTextColor()
Returns the color used to display user text, from the installed theme. |
static FontUIResource |
getUserTextFont()
Returns the font used for user text, obtained from the current theme. |
static ColorUIResource |
getWhite()
Returns the color used for white, from the installed theme. |
static ColorUIResource |
getWindowBackground()
Returns the window background color, from the installed theme. |
static ColorUIResource |
getWindowTitleBackground()
Returns the window title background color, from the installed theme. |
static FontUIResource |
getWindowTitleFont()
Returns the window title font from the current theme. |
static ColorUIResource |
getWindowTitleForeground()
Returns the window title foreground color, from the installed theme. |
static ColorUIResource |
getWindowTitleInactiveBackground()
Returns the background color for an inactive window title, from the installed theme. |
static ColorUIResource |
getWindowTitleInactiveForeground()
Returns the foreground color for an inactive window title, from the installed theme. |
protected void |
initClassDefaults(UIDefaults defaults)
Sets the ComponentUI classes for all Swing components to the Metal implementations. |
protected void |
initComponentDefaults(UIDefaults defaults)
Initializes the component defaults for the Metal Look & Feel. |
protected void |
initSystemColorDefaults(UIDefaults defaults)
Initializes the system color defaults. |
boolean |
isNativeLookAndFeel()
Returns false to indicate that this look and feel does not
attempt to emulate the look and feel of native applications on the host
platform. |
boolean |
isSupportedLookAndFeel()
Returns true to indicate that this look and feel is supported
on all platforms. |
static void |
setCurrentTheme(MetalTheme theme)
Sets the current theme for the look and feel. |
Methods inherited from class javax.swing.plaf.basic.BasicLookAndFeel |
---|
createAudioAction, getAudioActionMap, initialize, loadSystemColors, playSound, uninitialize |
Methods inherited from class javax.swing.LookAndFeel |
---|
getDesktopPropertyValue, installBorder, installColors, installColorsAndFont, installProperty, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, provideErrorFeedback, toString, uninstallBorder |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MetalLookAndFeel()
Method Detail |
---|
protected void createDefaultTheme()
DefaultMetalTheme
.
public boolean isNativeLookAndFeel()
false
to indicate that this look and feel does not
attempt to emulate the look and feel of native applications on the host
platform.
isNativeLookAndFeel
in class LookAndFeel
false
.public boolean isSupportedLookAndFeel()
true
to indicate that this look and feel is supported
on all platforms.
isSupportedLookAndFeel
in class LookAndFeel
true
.public String getDescription()
getDescription
in class LookAndFeel
public String getID()
getID
in class LookAndFeel
public String getName()
getName
in class LookAndFeel
public UIDefaults getDefaults()
BasicLookAndFeel
getDefaults
in class BasicLookAndFeel
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 ColorUIResource getDesktopColor()
public static ColorUIResource getFocusColor()
public static ColorUIResource getHighlightedTextColor()
public static ColorUIResource getInactiveControlTextColor()
public static ColorUIResource getInactiveSystemTextColor()
public static ColorUIResource getMenuBackground()
getMenuSelectedBackground()
public static ColorUIResource getMenuDisabledForeground()
getMenuForeground()
public static ColorUIResource getMenuForeground()
getMenuDisabledForeground()
,
getMenuSelectedForeground()
public static ColorUIResource getMenuSelectedBackground()
getMenuBackground()
public static ColorUIResource getMenuSelectedForeground()
getMenuForeground()
public static FontUIResource getMenuTextFont()
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 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()
MetalTheme
public static ColorUIResource getWindowTitleForeground()
public static ColorUIResource getWindowTitleInactiveBackground()
public static ColorUIResource getWindowTitleInactiveForeground()
public static void setCurrentTheme(MetalTheme theme)
MetalLookAndFeel
, first set the theme with this method, then
create a new instance of MetalLookAndFeel
and install it in the
usual way (see UIManager.setLookAndFeel(LookAndFeel)
).
theme
- the theme (null
not permitted).
NullPointerException
- if theme
is null
.getCurrentTheme()
protected void initClassDefaults(UIDefaults defaults)
Key | Value |
---|---|
ButtonUI | MetalButtonUI |
CheckBoxUI | MetalCheckBoxUI |
ComboBoxUI | MetalComboBoxUI |
DesktopIconUI | MetalDesktopIconUI |
InternalFrameUI | MetalInternalFrameUI |
LabelUI | MetalLabelUI |
PopupMenuSeparatorUI | MetalPopupMenuSeparatorUI |
ProgressBarUI | MetalProgressBarUI |
RadioButtonUI | MetalRadioButtonUI |
RootPaneUI | MetalRootPaneUI |
ScrollBarUI | MetalScrollBarUI |
ScrollPaneUI | MetalScrollPaneUI |
SeparatorUI | MetalSeparatorUI |
SliderUI | MetalSliderUI |
SplitPaneUI | MetalSplitPaneUI |
TabbedPaneUI | MetalTabbedPaneUI |
TextFieldUI | MetalTextFieldUI |
ToggleButtonUI | MetalToggleButtonUI |
ToolBarUI | MetalToolBarUI |
ToolTipUI | MetalToolTipUI |
TreeUI | MetalTreeUI |
initClassDefaults
in class BasicLookAndFeel
defaults
- the UIDefaults where the class defaults are addedprotected void initComponentDefaults(UIDefaults defaults)
Key | Value |
---|---|
Button.background | 0xcccccc |
Button.border | MetalBorders.getButtonBorder() |
Button.font | getControlTextFont() |
Button.margin | new java.awt.Insets(2, 14, 2, 14)
|
CheckBox.background | 0xcccccc |
CheckBoxMenuItem.background | 0xcccccc |
ToolBar.background | 0xcccccc |
Panel.background | 0xcccccc |
Slider.background | 0xcccccc |
OptionPane.background | 0xcccccc |
ProgressBar.background | 0xcccccc |
TabbedPane.background | 0xcccccc |
Label.background | 0xcccccc |
Label.font | getControlTextFont() |
Menu.background | 0xcccccc |
MenuBar.background | 0xcccccc |
MenuItem.background | 0xcccccc |
ScrollBar.background | 0xcccccc |
PopupMenu.border | new javax.swing.plaf.metal.MetalBorders.PopupMenuBorder() |
initComponentDefaults
in class BasicLookAndFeel
defaults
- the UIDefaults instance to which the values are addedprotected void initSystemColorDefaults(UIDefaults defaults)
Key | Value | Description |
---|---|---|
control | 0xcccccc | The default color for components |
initSystemColorDefaults
in class BasicLookAndFeel
defaults
- the defaults table (null
not permitted).public static MetalTheme getCurrentTheme()
OceanTheme
.
null
).setCurrentTheme(MetalTheme)
public boolean getSupportsWindowDecorations()
true
because the Metal look
and feel supports window decorations for toplevel
containers.
getSupportsWindowDecorations
in class LookAndFeel
true
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |