java.lang.Object
javax.swing.LookAndFeel
javax.swing.plaf.basic.BasicLookAndFeel
javax.swing.plaf.metal.MetalLookAndFeel
- 所有已实现的接口:
-
Serializable
Java外观,又称为Metal。
MetalLookAndFeel提供的每个ComponentUI都从默认表中获取其行为。除非另有说明,否则此包中的每个ComponentUI实现都记录了它们使用的默认值集。除非另有说明,默认值在调用installUI时安装,并遵循LookAndFeel中概述的建议安装默认值。
MetalLookAndFeel从MetalTheme派生其颜色调色板和字体。默认主题是OceanTheme。可以使用setCurrentTheme方法更改主题,请参阅有关更改主题的详细信息。在1.5之前,默认主题是DefaultMetalTheme。系统属性"swing.metalTheme"可以设置为"steel"以指示默认应为DefaultMetalTheme。
警告: 此类的序列化对象将与未来的Swing版本不兼容。当前的序列化支持适用于短期存储或在运行相同版本的Swing应用程序之间进行RMI。从1.4开始,已将所有JavaBeans的长期存储支持添加到java.beans包中。请参阅XMLEncoder。
- 参见:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void确保当前的MetalTheme不为null。static ColorUIResource返回当前主题的加速器前景色。static ColorUIResource返回当前主题的已选择加速器前景色。static ColorUIResourcegetBlack()返回当前主题的黑色。static ColorUIResource返回当前主题的控件颜色。static ColorUIResource返回当前主题的控件深阴影颜色。static ColorUIResource返回当前主题的已禁用控件颜色。static ColorUIResource返回当前主题的控件高亮颜色。static ColorUIResource返回当前主题的控件信息颜色。static ColorUIResource返回当前主题的控件阴影颜色。static ColorUIResource返回当前主题的控件文本颜色。static FontUIResource返回当前主题的控件文本字体。static MetalTheme返回当前由MetalLookAndFeel使用的主题。返回外观的默认值。返回此外观的简短描述。static ColorUIResource返回当前主题的桌面颜色。getDisabledIcon(JComponent component, Icon icon) 返回具有禁用外观的Icon。getDisabledSelectedIcon(JComponent component, Icon icon) 返回供已选择的禁用组件使用的Icon。static ColorUIResource返回当前主题的焦点颜色。static ColorUIResource返回当前主题的突出显示文本颜色。getID()返回此外观的标识符。static ColorUIResource返回当前主题的非活动控件文本颜色。static ColorUIResource返回当前主题的非活动系统文本颜色。返回实现Java外观设计指南的LayoutStyle。static ColorUIResource返回当前主题的菜单背景颜色。static ColorUIResource返回当前主题的菜单已禁用前景色。static ColorUIResource返回当前主题的菜单前景色。static ColorUIResource返回当前主题的菜单已选择背景颜色。static ColorUIResource返回当前主题的菜单已选择前景色。static FontUIResource返回当前主题的菜单文本字体。getName()返回此外观的名称。static ColorUIResource返回当前主题的主控件颜色。static ColorUIResource返回当前主题的主控件深阴影颜色。static ColorUIResource返回当前主题的主控件高亮颜色。static ColorUIResource返回当前主题的主控件信息颜色。static ColorUIResource返回当前主题的主控件阴影颜色。static ColorUIResource返回当前主题的分隔符背景颜色。static ColorUIResource返回当前主题的分隔符前景颜色。static FontUIResource返回当前主题的子文本字体。boolean返回true; Metal可以提供Window装饰。static ColorUIResource返回当前主题的系统文本颜色。static FontUIResource返回当前主题的系统文本字体。static ColorUIResource返回当前主题的文本高亮颜色。static ColorUIResource返回当前主题的用户文本颜色。static FontUIResource返回当前主题的用户文本字体。static ColorUIResourcegetWhite()返回当前主题的白色。static ColorUIResource返回当前主题的窗口背景颜色。static ColorUIResource返回当前主题的窗口标题背景颜色。static FontUIResource返回当前主题的窗口标题字体。static ColorUIResource返回当前主题的窗口标题前景颜色。static ColorUIResource返回当前主题的窗口标题非活动背景颜色。static ColorUIResource返回当前主题的窗口标题非活动前景颜色。protected voidinitClassDefaults(UIDefaults table) 使用uiClassID到ui类的完全限定名称的映射填充table。protected voidinitComponentDefaults(UIDefaults table) 使用metal的默认值填充table。protected void使用系统颜色填充table。boolean返回false;MetalLookAndFeel不是本机外观。boolean返回true;MetalLookAndFeel可以在任何平台上运行。voidprovideErrorFeedback(Component component) 当用户尝试无效操作(例如粘贴到具有焦点的不可编辑的JTextField)时调用。static voidsetCurrentTheme(MetalTheme theme) 设置MetalLookAndFeel使用的主题。Methods declared in class javax.swing.plaf.basic.BasicLookAndFeel
createAudioAction, getAudioActionMap, loadSystemColors, playSoundMethods declared in class javax.swing.LookAndFeel
getDesktopPropertyValue, initialize, installBorder, installColors, installColorsAndFont, installProperty, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, toString, uninitialize, uninstallBorder
-
Constructor Details
-
MetalLookAndFeel
public MetalLookAndFeel()构造一个MetalLookAndFeel。
-
-
Method Details
-
getName
返回此外观的名称。这将返回"Metal"。- 指定者:
-
getName在类LookAndFeel中 - 返回:
- 此外观的名称
-
getID
返回此外观的标识符。这将返回"Metal"。- 指定者:
-
getID在类LookAndFeel中 - 返回:
- 此外观的标识符
-
getDescription
返回此外观的简短描述。这将返回"The Java(tm) Look and Feel"。- 指定者:
-
getDescription在类LookAndFeel中 - 返回:
- 此外观的简短描述
-
isNativeLookAndFeel
public boolean isNativeLookAndFeel()返回false;MetalLookAndFeel不是本机外观。- 指定者:
-
isNativeLookAndFeel在类LookAndFeel中 - 返回:
-
false
-
isSupportedLookAndFeel
public boolean isSupportedLookAndFeel()返回true;MetalLookAndFeel可以在任何平台上运行。- 指定者:
-
isSupportedLookAndFeel在类LookAndFeel中 - 返回:
-
true - 参见:
-
getSupportsWindowDecorations
public boolean getSupportsWindowDecorations()返回true; Metal可以提供Window装饰。- 覆盖:
-
getSupportsWindowDecorations在类LookAndFeel中 - 返回:
-
true - 自:
- 1.4
- 参见:
-
initClassDefaults
使用uiClassID到ui类的完全限定名称的映射填充table。MetalLookAndFeel为javax.swing.plaf.metal包中命名为MetalXXXUI的每个类注册一个条目。字符串XXX是Swing的uiClassIDs之一。对于在metal中没有类的uiClassIDs,将使用javax.swing.plaf.basic中的相应类。例如,metal没有名为"MetalColorChooserUI"的类,因此使用javax.swing.plaf.basic.BasicColorChooserUI。- 覆盖:
-
initClassDefaults在类BasicLookAndFeel中 - 参数:
-
table- 要添加条目的UIDefaults实例 - 抛出:
-
NullPointerException- 如果table为null - 参见:
-
initSystemColorDefaults
使用系统颜色填充table。以下值将添加到table中:
值Metal的系统颜色映射 键 值 "desktop" theme.getDesktopColor()"activeCaption" theme.getWindowTitleBackground()"activeCaptionText" theme.getWindowTitleForeground()"activeCaptionBorder" theme.getPrimaryControlShadow()"inactiveCaption" theme.getWindowTitleInactiveBackground()"inactiveCaptionText" theme.getWindowTitleInactiveForeground()"inactiveCaptionBorder" theme.getControlShadow()"window" theme.getWindowBackground()"windowBorder" theme.getControl()"windowText" theme.getUserTextColor()"menu" theme.getMenuBackground()"menuText" theme.getMenuForeground()"text" theme.getWindowBackground()"textText" theme.getUserTextColor()"textHighlight" theme.getTextHighlightColor()"textHighlightText" theme.getHighlightedTextColor()"textInactiveText" theme.getInactiveSystemTextColor()"control" theme.getControl()"controlText" theme.getControlTextColor()"controlHighlight" theme.getControlHighlight()"controlLtHighlight" theme.getControlHighlight()"controlShadow" theme.getControlShadow()"controlDkShadow" theme.getControlDarkShadow()"scrollbar" theme.getControl()"info" theme.getPrimaryControl()"infoText" theme.getPrimaryControlInfo()theme对应于当前的MetalTheme。- 覆盖:
-
initSystemColorDefaults在类BasicLookAndFeel中 - 参数:
-
table- 要添加值的UIDefaults对象 - 抛出:
-
NullPointerException- 如果table为null - 参见:
-
initComponentDefaults
使用默认值填充table以供metal使用。- 覆盖:
-
initComponentDefaults在类BasicLookAndFeel中 - 参数:
-
table- 要添加值的UIDefaults - 抛出:
-
NullPointerException- 如果table为null
-
createDefaultTheme
protected void createDefaultTheme()确保当前的MetalTheme为非null。这是getCurrentTheme的封装方法。- 参见:
-
getDefaults
返回外观的默认值。按顺序调用createDefaultTheme()、super.getDefaults()和getCurrentTheme().addCustomEntriesToTable(table)。虽然此方法是公共的,但应该仅在外观设置为当前外观并且调用了
initialize之后由UIManager调用。- 覆盖:
-
getDefaults在类BasicLookAndFeel中 - 返回:
- 外观的默认值
- 参见:
-
provideErrorFeedback
当用户尝试无效操作(例如粘贴到具有焦点的不可编辑的JTextField)时调用。默认实现会发出哔声。希望提供不同行为的子类应该覆盖此方法并提供额外的反馈。- 覆盖:
-
provideErrorFeedback在类LookAndFeel中 - 参数:
-
component- 发生错误的Component,可能为null,表示错误条件与Component无直接关联 - 自:
- 1.4
-
setCurrentTheme
设置MetalLookAndFeel使用的主题。设置主题后,需要重新安装
MetalLookAndFeel并重新创建UI。以下显示如何执行此操作:MetalLookAndFeel.setCurrentTheme(theme); // 重新安装Metal外观 UIManager.setLookAndFeel(new MetalLookAndFeel()); // 更新所有组件的ComponentUI。这 // 需要对所有窗口调用。 SwingUtilities.updateComponentTreeUI(rootComponent);
如果不这样做,结果是不确定的。- 参数:
-
theme- 要使用的主题 - 抛出:
-
NullPointerException- 如果theme为null - 参见:
-
getCurrentTheme
返回MetalLookAndFeel当前使用的主题。如果当前主题为null,则创建默认主题。- 返回:
- 当前主题
- 自:
- 1.5
- 参见:
-
getDisabledIcon
返回具有禁用外观的Icon。当未指定禁用Icon时,此方法用于生成禁用Icon。例如,如果创建JButton并仅通过setIcon指定Icon,则将调用此方法生成禁用Icon。如果将icon传递为null,则此方法返回null。某些外观可能不会呈现禁用的图标,在这种情况下,它们将忽略此操作。
- 覆盖:
-
getDisabledIcon在类LookAndFeel中 - 参数:
-
component- 将显示图标的JComponent,可能为null -
icon- 生成禁用图标的图标。 - 返回:
-
禁用图标,如果无法生成合适的图标,则返回
null。 - 自:
- 1.5
-
getDisabledSelectedIcon
返回用于同时处于禁用和选定状态的组件的Icon。此方法用于为处于禁用和选定状态但没有特定Icon的组件生成Icon。例如,如果创建JButton并仅通过setIcon指定Icon,则将调用此方法生成禁用和选定的Icon。如果将icon传递为null,则此方法返回null。某些外观可能不会呈现禁用和选定的图标,在这种情况下,它们将忽略此操作。
- 覆盖:
-
getDisabledSelectedIcon在类LookAndFeel - 参数:
-
component- 将显示图标的 JComponent,可以为 null -
icon- 用于生成禁用和选定图标的图标。 - 返回:
- 禁用和选定图标,如果无法生成合适的图标则返回 null。
- 自:
- 1.5
-
getControlTextFont
返回当前主题的控件文本字体。这是getCurrentTheme().getControlTextColor()的封装方法。- 返回:
- 控件文本字体
- 参见:
-
getSystemTextFont
返回当前主题的系统文本字体。这是getCurrentTheme().getSystemTextFont()的封装方法。- 返回:
- 系统文本字体
- 参见:
-
getUserTextFont
返回当前主题的用户文本字体。这是getCurrentTheme().getUserTextFont()的封装方法。- 返回:
- 用户文本字体
- 参见:
-
getMenuTextFont
返回当前主题的菜单文本字体。这是getCurrentTheme().getMenuTextFont()的封装方法。- 返回:
- 菜单文本字体
- 参见:
-
getWindowTitleFont
返回当前主题的窗口标题字体。这是getCurrentTheme().getWindowTitleFont()的封装方法。- 返回:
- 窗口标题字体
- 参见:
-
getSubTextFont
返回当前主题的子文本字体。这是getCurrentTheme().getSubTextFont()的封装方法。- 返回:
- 子文本字体
- 参见:
-
getDesktopColor
返回当前主题的桌面颜色。这是getCurrentTheme().getDesktopColor()的封装方法。- 返回:
- 桌面颜色
- 参见:
-
getFocusColor
返回当前主题的焦点颜色。这是getCurrentTheme().getFocusColor()的封装方法。- 返回:
- 焦点颜色
- 参见:
-
getWhite
返回当前主题的白色。这是getCurrentTheme().getWhite()的封装方法。- 返回:
- 白色
- 参见:
-
getBlack
返回当前主题的黑色。这是getCurrentTheme().getBlack()的封装方法。- 返回:
- 黑色
- 参见:
-
getControl
返回当前主题的控件颜色。这是getCurrentTheme().getControl()的封装方法。- 返回:
- 控件颜色
- 参见:
-
getControlShadow
返回当前主题的控件阴影颜色。这是getCurrentTheme().getControlShadow()的封装方法。- 返回:
- 控件阴影颜色
- 参见:
-
getControlDarkShadow
返回当前主题的控件深色阴影颜色。这是getCurrentTheme().getControlDarkShadow()的封装方法。- 返回:
- 控件深色阴影颜色
- 参见:
-
getControlInfo
返回当前主题的控件信息颜色。这是getCurrentTheme().getControlInfo()的封装方法。- 返回:
- 控件信息颜色
- 参见:
-
getControlHighlight
返回当前主题的控件高亮颜色。这是getCurrentTheme().getControlHighlight()的封装方法。- 返回:
- 控件高亮颜色
- 参见:
-
getControlDisabled
返回当前主题的控件禁用颜色。这是getCurrentTheme().getControlDisabled()的封装方法。- 返回:
- 控件禁用颜色
- 参见:
-
getPrimaryControl
返回当前主题的主要控件颜色。这是getCurrentTheme().getPrimaryControl()的封装方法。- 返回:
- 主要控件颜色
- 参见:
-
getPrimaryControlShadow
返回当前主题的主要控件阴影颜色。这是getCurrentTheme().getPrimaryControlShadow()的封装方法。- 返回:
- 主要控件阴影颜色
- 参见:
-
getPrimaryControlDarkShadow
返回当前主题的主要控件深色阴影颜色。这是getCurrentTheme().getPrimaryControlDarkShadow()的封装方法。- 返回:
- 主要控件深色阴影颜色
- 参见:
-
getPrimaryControlInfo
返回当前主题的主要控件信息颜色。这是getCurrentTheme().getPrimaryControlInfo()的封装方法。- 返回:
- 主要控件信息颜色
- 参见:
-
getPrimaryControlHighlight
返回当前主题的主要控件高亮颜色。这是getCurrentTheme().getPrimaryControlHighlight()的封装方法。- 返回:
- 主要控件高亮颜色
- 参见:
-
getSystemTextColor
返回当前主题的系统文本颜色。这是getCurrentTheme().getSystemTextColor()的封装方法。- 返回:
- 系统文本颜色
- 参见:
-
getControlTextColor
返回当前主题的控件文本颜色。这是getCurrentTheme().getControlTextColor()的封装方法。- 返回:
- 控件文本颜色
- 参见:
-
getInactiveControlTextColor
返回当前主题的非活动控件文本颜色。这是getCurrentTheme().getInactiveControlTextColor()的封装方法。- 返回:
- 非活动控件文本颜色
- 参见:
-
getInactiveSystemTextColor
返回当前主题的非活动系统文本颜色。这是getCurrentTheme().getInactiveSystemTextColor()的封装方法。- 返回:
- 非活动系统文本颜色
- 参见:
-
getUserTextColor
返回当前主题的用户文本颜色。这是getCurrentTheme().getUserTextColor()的封装方法。- 返回:
- 用户文本颜色
- 参见:
-
getTextHighlightColor
返回当前主题的文本高亮颜色。这是getCurrentTheme().getTextHighlightColor()的封装方法。- 返回:
- 文本高亮颜色
- 参见:
-
getHighlightedTextColor
返回当前主题的突出显示文本颜色。这是getCurrentTheme().getHighlightedTextColor()的封装方法。- 返回:
- 突出显示文本颜色
- 参见:
-
getWindowBackground
返回当前主题的窗口背景颜色。这是getCurrentTheme().getWindowBackground()的封装方法。- 返回:
- 窗口背景颜色
- 参见:
-
getWindowTitleBackground
返回当前主题的窗口标题背景颜色。这是getCurrentTheme().getWindowTitleBackground()的封装方法。- 返回:
- 窗口标题背景颜色
- 参见:
-
getWindowTitleForeground
返回当前主题的窗口标题前景颜色。这是getCurrentTheme().getWindowTitleForeground()的封装方法。- 返回:
- 窗口标题前景颜色
- 参见:
-
getWindowTitleInactiveBackground
返回当前主题的窗口标题非活动背景颜色。这是getCurrentTheme().getWindowTitleInactiveBackground()的封装方法。- 返回:
- 窗口标题非活动背景颜色
- 参见:
-
getWindowTitleInactiveForeground
返回当前主题的窗口标题非活动前景颜色。这是getCurrentTheme().getWindowTitleInactiveForeground()的封装方法。- 返回:
- 窗口标题非活动前景颜色
- 参见:
-
getMenuBackground
返回当前主题的菜单背景颜色。这是getCurrentTheme().getMenuBackground()的封装方法。- 返回:
- 菜单背景颜色
- 参见:
-
getMenuForeground
返回当前主题的菜单前景颜色。这是getCurrentTheme().getMenuForeground()的封装方法。- 返回:
- 菜单前景颜色
- 参见:
-
getMenuSelectedBackground
返回当前主题的菜单选定背景颜色。这是getCurrentTheme().getMenuSelectedBackground()的封装方法。- 返回:
- 菜单选定背景颜色
- 参见:
-
getMenuSelectedForeground
返回当前主题的菜单选定前景颜色。这是getCurrentTheme().getMenuSelectedForeground()的封装方法。- 返回:
- 菜单选定前景颜色
- 参见:
-
getMenuDisabledForeground
返回当前主题的菜单禁用前景颜色。这是getCurrentTheme().getMenuDisabledForeground()的封装方法。- 返回:
- 菜单禁用前景颜色
- 参见:
-
getSeparatorBackground
返回当前主题的分隔符背景颜色。这是getCurrentTheme().getSeparatorBackground()的封装方法。- 返回:
- 分隔符背景颜色
- 参见:
-
getSeparatorForeground
返回当前主题的分隔符前景颜色。这是getCurrentTheme().getSeparatorForeground()的封装方法。- 返回:
- 分隔符前景颜色
- 参见:
-
getAcceleratorForeground
返回当前主题的加速键前景颜色。这是getCurrentTheme().getAcceleratorForeground()的封装方法。- 返回:
- 加速键前景颜色
- 参见:
-
getAcceleratorSelectedForeground
返回当前主题的选定加速键前景颜色。这是getCurrentTheme().getAcceleratorSelectedForeground()的封装方法。- 返回:
- 选定加速键前景颜色
- 参见:
-
getLayoutStyle
返回实现Java外观设计准则的LayoutStyle。- 覆盖:
-
getLayoutStyle在类LookAndFeel - 返回:
- 实现Java外观设计准则的LayoutStyle
- 自:
- 1.6
- 参见:
-