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
。
Warning: 此类的序列化对象将与未来的 Swing 版本不兼容。当前的序列化支持适用于运行相同版本 Swing 的应用程序之间的短期存储或 RMI。从 1.4 开始,对所有 JavaBeans 的长期存储的支持已添加到 java.beans
包中。请参阅 XMLEncoder
。
- 参见:
-
构造方法总结
构造方法 -
方法总结
修饰符和类型方法描述protected void
确保当前的MetalTheme
是non-null
。static ColorUIResource
返回当前主题的加速器前景色。static ColorUIResource
返回当前主题的加速器选择的前景色。static ColorUIResource
getBlack()
返回当前主题的黑色。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
;金属可以提供Window
装饰品。static ColorUIResource
返回当前主题的系统文本颜色。static FontUIResource
返回当前主题的系统文本字体。static ColorUIResource
返回当前主题的文本高亮颜色。static ColorUIResource
返回当前主题的用户文本颜色。static FontUIResource
返回当前主题的用户文本字体。static ColorUIResource
getWhite()
返回当前主题的白色。static ColorUIResource
返回当前主题的窗口背景颜色。static ColorUIResource
返回当前主题的窗口标题背景色。static FontUIResource
返回当前主题的窗口标题字体。static ColorUIResource
返回当前主题的窗口标题前景色。static ColorUIResource
返回当前主题的窗口标题非活动背景颜色。static ColorUIResource
返回当前主题的窗口标题非活动前景色。protected void
initClassDefaults
(UIDefaults table) 使用从uiClassID
到 ui 类的完全限定名称的映射填充table
。protected void
initComponentDefaults
(UIDefaults table) 使用金属的默认值填充table
。protected void
使用系统颜色填充table
。boolean
返回false
;MetalLookAndFeel
不是本机外观。boolean
返回true
;MetalLookAndFeel
可以在任何平台上运行。void
provideErrorFeedback
(Component component) 当用户尝试无效操作时调用,例如粘贴到具有焦点的不可编辑的JTextField
中。static void
setCurrentTheme
(MetalTheme theme) 设置MetalLookAndFeel
使用的主题。在类 javax.swing.plaf.basic.BasicLookAndFeel 中声明的方法
createAudioAction, getAudioActionMap, loadSystemColors, playSound
-
构造方法详细信息
-
MetalLookAndFeel
public MetalLookAndFeel()构造一个MetalLookAndFeel
-
-
方法详情
-
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
;金属可以提供Window
装饰品。- 重写:
getSupportsWindowDecorations
在类LookAndFeel
中- 返回:
true
- 自从:
- 1.4
- 参见:
-
initClassDefaults
使用从uiClassID
到 ui 类的完全限定名称的映射填充table
。MetalLookAndFeel
为包javax.swing.plaf.metal
中名为 MetalXXXUI 的每个类注册一个条目。字符串XXX
是 Swing 的 uiClassID 之一。对于金属中没有类的uiClassIDs
,使用javax.swing.plaf.basic
中的相应类。例如,金属没有名为"MetalColorChooserUI"
的类,因此使用javax.swing.plaf.basic.BasicColorChooserUI
。- 重写:
initClassDefaults
在类BasicLookAndFeel
中- 参数:
table
- 条目添加到的UIDefaults
实例- 抛出:
NullPointerException
- 如果table
是null
- 参见:
-
initSystemColorDefaults
使用系统颜色填充table
。以下值添加到table
:Metal 的系统颜色映射 Key Value “桌面” theme.getDesktopColor()
“主动字幕” theme.getWindowTitleBackground()
“活动字幕文本” theme.getWindowTitleForeground()
“活动字幕边框” theme.getPrimaryControlShadow()
“inactiveCaption” theme.getWindowTitleInactiveBackground()
“无效的字幕文本” theme.getWindowTitleInactiveForeground()
“无效的字幕边框” theme.getControlShadow()
“窗户” theme.getWindowBackground()
"windowBorder" theme.getControl()
“窗口文本” theme.getUserTextColor()
"menu" theme.getMenuBackground()
“菜单文本” theme.getMenuForeground()
"text" theme.getWindowBackground()
"textText" theme.getUserTextColor()
“文本突出显示” theme.getTextHighlightColor()
“文本高亮文本” theme.getHighlightedTextColor()
“文本无效文本” theme.getInactiveSystemTextColor()
“控制” theme.getControl()
“控制文本” theme.getControlTextColor()
“控制亮点” theme.getControlHighlight()
“控制LtHighlight” theme.getControlHighlight()
“控制阴影” theme.getControlShadow()
“controlDkShadow” theme.getControlDarkShadow()
"scrollbar" theme.getControl()
“信息” theme.getPrimaryControl()
“信息文本” theme.getPrimaryControlInfo()
theme
对应于当前的MetalTheme
。- 重写:
initSystemColorDefaults
在类BasicLookAndFeel
中- 参数:
table
- 将值添加到的UIDefaults
对象- 抛出:
NullPointerException
- 如果table
是null
- 参见:
-
initComponentDefaults
使用金属的默认值填充table
。- 重写:
initComponentDefaults
在类BasicLookAndFeel
中- 参数:
table
- 要将值添加到的UIDefaults
- 抛出:
NullPointerException
- 如果table
是null
-
createDefaultTheme
protected void createDefaultTheme()确保当前的MetalTheme
是non-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
需要重新安装,需要重新制作uis。下面显示了如何执行此操作: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);
如果不这样做,结果是不确定的。- 参数:
theme
- 使用的主题- 抛出:
NullPointerException
- 如果theme
是null
- 参见:
-
getCurrentTheme
返回MetalLookAndFeel
当前使用的主题。如果当前主题是null
,则创建默认主题。- 返回:
- 当前主题
- 自从:
- 1.5
- 参见:
-
getDisabledIcon
返回具有禁用外观的Icon
。此方法用于在未指定时生成禁用的Icon
。例如,如果您创建一个JButton
并且仅通过setIcon
指定一个Icon
将调用此方法来生成禁用的Icon
。如果 null 作为icon
传递,则此方法返回 null。某些外观可能不会呈现禁用的图标,在这种情况下,它们将忽略它。
- 重写:
getDisabledIcon
在类LookAndFeel
中- 参数:
component
- 将显示图标的 JComponent,可能为 nullicon
- 从中生成禁用图标的图标。- 返回:
- 禁用图标,如果无法生成合适的图标,则为 null。
- 自从:
- 1.5
-
getDisabledSelectedIcon
返回一个Icon
供同时被选中的禁用组件使用。此方法用于为同时处于禁用和选中状态但没有针对此状态的特定Icon
的组件生成Icon
。例如,如果您创建一个JButton
并且仅通过setIcon
指定一个Icon
,则将调用此方法来生成禁用和选定的Icon
。如果 null 作为icon
传递,则此方法返回 null。某些外观可能不会呈现禁用和选定的图标,在这种情况下,它们将忽略这一点。
- 重写:
getDisabledSelectedIcon
在类LookAndFeel
中- 参数:
component
- 将显示图标的 JComponent,可能为 nullicon
- 从中生成禁用和选定图标的图标。- 返回:
- Disabled 和 Selected 图标,如果无法生成合适的图标,则为 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
中- 返回:
- LayoutStyle 实现 Java 外观设计指南
- 自从:
- 1.6
- 参见:
-