|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjavax.swing.LookAndFeel
javax.swing.plaf.basic.BasicLookAndFeel
javax.swing.plaf.metal.MetalLookAndFeel
public class MetalLookAndFeel
Java 外观,也称为 Metal。
每个由 MetalLookAndFeel 提供的 ComponentUI 从默认表中派生其行为。除非另行说明,否则此包中每个 ComponentUI 实现都记录它们所使用的默认值集合。除非另行说明,否则调用 installUI 时,将安装默认值并遵循 LookAndFeel 中描述的安装默认值的建议。
MetalLookAndFeel 从 MetalTheme 派生其调色板和字体。默认主题为 OceanTheme。可以使用 setCurrentTheme 方法更改主题,有关更改主题的详细信息,请参阅该方法。在 1.5 之前,默认主题为 DefaultMetalTheme。可以将系统属性 "swing.metalTheme" 设置为 "steel",指示默认主题应该为 DefaultMetalTheme。
警告:此类的序列化对象与以后的 Swing 版本不兼容。当前序列化支持适用于短期存储,或适用于在运行相同 Swing 版本的应用程序之间进行 RMI(Remote Method Invocation,远程方法调用)。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder。
MetalTheme,
DefaultMetalTheme,
OceanTheme| 构造方法摘要 | |
|---|---|
MetalLookAndFeel()
|
|
| 从类 javax.swing.plaf.basic.BasicLookAndFeel 继承的方法 |
|---|
createAudioAction, getAudioActionMap, initialize, loadSystemColors, playSound, uninitialize |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 构造方法详细信息 |
|---|
public MetalLookAndFeel()
| 方法详细信息 |
|---|
public String getName()
"Metal"。
LookAndFeel 中的 getNamepublic String getID()
"Metal"。
LookAndFeel 中的 getIDpublic String getDescription()
"The Java(tm) Look and Feel"。
LookAndFeel 中的 getDescriptionpublic boolean isNativeLookAndFeel()
false;MetalLookAndFeel 不是本机外观。
LookAndFeel 中的 isNativeLookAndFeelfalsepublic boolean isSupportedLookAndFeel()
true;可以在任意平台上运行 MetalLookAndFeel。
LookAndFeel 中的 isSupportedLookAndFeeltrueUIManager.setLookAndFeel(javax.swing.LookAndFeel)public boolean getSupportsWindowDecorations()
true; metal 可以提供 Window 装饰。
LookAndFeel 中的 getSupportsWindowDecorationstrueJDialog.setDefaultLookAndFeelDecorated(boolean),
JFrame.setDefaultLookAndFeelDecorated(boolean),
JRootPane.setWindowDecorationStyle(int)protected void initClassDefaults(UIDefaults table)
uiClassID 到 ui 类完全限定名的映射关系填充 table。MetalLookAndFeel 在名为 MetalXXXUI 的 javax.swing.plaf.metal 包为每个类注册一个条目。字符串 XXX 为 Swing 的一个 uiClassID。对于在 metal 中没有类的 uiClassID,使用 javax.swing.plaf.basic 中对应的类。例如,metal 没有名为 "MetalColorChooserUI" 的类,这种情况下使用 javax.swing.plaf.basic.BasicColorChooserUI。
BasicLookAndFeel 中的 initClassDefaultstable - 要添加条目的 UIDefaults 实例
NullPointerException - 如果 table 为 nullBasicLookAndFeel.initClassDefaults(javax.swing.UIDefaults)protected void initSystemColorDefaults(UIDefaults table)
table。将以下值添加到 table:
| Key | Value |
|---|---|
| "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。
BasicLookAndFeel 中的 initSystemColorDefaultstable - 要添加值的 UIDefaults 对象
NullPointerException - 如果 table 为 nullSystemColor,
BasicLookAndFeel.getDefaults(),
BasicLookAndFeel.loadSystemColors(javax.swing.UIDefaults, java.lang.String[], boolean)protected void initComponentDefaults(UIDefaults table)
table。
BasicLookAndFeel 中的 initComponentDefaultstable - 要添加值的 UIDefaults
NullPointerException - 如果 table 为 nullprotected void createDefaultTheme()
MetalTheme 为非 null。此方法是 getCurrentTheme 的覆盖方法。
getCurrentTheme()public UIDefaults getDefaults()
createDefaultTheme()、super.getDefaults() 和 getCurrentTheme().addCustomEntriesToTable(table)。
虽然此方法是公共方法,但只当外观被设置为当前外观并调用了 initialize 之后才应该由 UIManager 调用此方法。
BasicLookAndFeel 中的 getDefaultscreateDefaultTheme(),
BasicLookAndFeel.getDefaults(),
MetalTheme.addCustomEntriesToTable(UIDefaults)public void provideErrorFeedback(Component component)
JTextField 中进行粘贴。默认实现蜂鸣。期待不同行为的子类应重写它,并提供其他的反馈。
LookAndFeel 中的 provideErrorFeedbackcomponent - 其中发生错误的 Component,可以为 null,指示错误条件与某个 Component 并无直接关联public static void setCurrentTheme(MetalTheme theme)
MetalLookAndFeel 使用的主题。
设置主题后,需要重新安装 MetalLookAndFeel 并重新创建 ui。以下代码说明了如何完成此操作:
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 为 nullgetCurrentTheme()public static MetalTheme getCurrentTheme()
MetalLookAndFeel 当前正在使用的主题。如果当前主题为 null,则创建默认主题。
setCurrentTheme(javax.swing.plaf.metal.MetalTheme)
public Icon getDisabledIcon(JComponent component,
Icon icon)
Icon。此方法用于在未指定图标时生成被禁用的 Icon。例如,如果创建了一个 JButton,并通过 setIcon 仅指定了一个 Icon,则会调用此方法来生成禁用的 Icon。如果将 null 作为 icon 传递,则此方法返回 null。
某些外观可能无法呈现禁用图标,在此情况下,外观将忽略此图标。
LookAndFeel 中的 getDisabledIconcomponent - 将显示 Icon 的 JComponent,可以为 nullicon - 从其生成禁用图标的 Icon。
public Icon getDisabledSelectedIcon(JComponent component,
Icon icon)
Icon。此方法用于为以下情况的组件生成一个 Icon:这些组件均为禁用和选中状态,但没有此状态的指定 Icon。例如,如果创建了一个 JButton,并通过 setIcon 仅指定了一个 Icon,则会调用此方法来生成被禁用和选中的 Icon。如果将 null 作为 icon 传递,则此方法返回 null。
有些外观可能不呈现禁用和选中的 Icon,在此情况下这些外观将忽略它。
LookAndFeel 中的 getDisabledSelectedIconcomponent - 将显示 Icon 的 JComponent,可以为 nullicon - 从其生成禁用和选中图标的 Icon。
public static FontUIResource getControlTextFont()
getCurrentTheme().getControlTextColor() 的覆盖方法。
MetalThemepublic static FontUIResource getSystemTextFont()
getCurrentTheme().getSystemTextFont() 的覆盖方法。
MetalThemepublic static FontUIResource getUserTextFont()
getCurrentTheme().getUserTextFont() 的覆盖方法。
MetalThemepublic static FontUIResource getMenuTextFont()
getCurrentTheme().getMenuTextFont() 的覆盖方法。
MetalThemepublic static FontUIResource getWindowTitleFont()
getCurrentTheme().getWindowTitleFont() 的覆盖方法。
MetalThemepublic static FontUIResource getSubTextFont()
getCurrentTheme().getSubTextFont() 的覆盖方法。
MetalThemepublic static ColorUIResource getDesktopColor()
getCurrentTheme().getDesktopColor() 的覆盖方法。
MetalThemepublic static ColorUIResource getFocusColor()
getCurrentTheme().getFocusColor() 的覆盖方法。
MetalThemepublic static ColorUIResource getWhite()
getCurrentTheme().getWhite() 的覆盖方法。
MetalThemepublic static ColorUIResource getBlack()
getCurrentTheme().getBlack() 的覆盖方法。
MetalThemepublic static ColorUIResource getControl()
getCurrentTheme().getControl() 的覆盖方法。
MetalThemepublic static ColorUIResource getControlShadow()
getCurrentTheme().getControlShadow() 的覆盖方法。
MetalThemepublic static ColorUIResource getControlDarkShadow()
getCurrentTheme().getControlDarkShadow() 的覆盖方法。
MetalThemepublic static ColorUIResource getControlInfo()
getCurrentTheme().getControlInfo() 的覆盖方法。
MetalThemepublic static ColorUIResource getControlHighlight()
getCurrentTheme().getControlHighlight() 的覆盖方法。
MetalThemepublic static ColorUIResource getControlDisabled()
getCurrentTheme().getControlDisabled() 的覆盖方法。
MetalThemepublic static ColorUIResource getPrimaryControl()
getCurrentTheme().getPrimaryControl() 的覆盖方法。
MetalThemepublic static ColorUIResource getPrimaryControlShadow()
getCurrentTheme().getPrimaryControlShadow() 的覆盖方法。
MetalThemepublic static ColorUIResource getPrimaryControlDarkShadow()
getCurrentTheme().getPrimaryControlDarkShadow() 的覆盖方法。
MetalThemepublic static ColorUIResource getPrimaryControlInfo()
getCurrentTheme().getPrimaryControlInfo() 的覆盖方法。
MetalThemepublic static ColorUIResource getPrimaryControlHighlight()
getCurrentTheme().getPrimaryControlHighlight() 的覆盖方法。
MetalThemepublic static ColorUIResource getSystemTextColor()
getCurrentTheme().getSystemTextColor() 的覆盖方法。
MetalThemepublic static ColorUIResource getControlTextColor()
getCurrentTheme().getControlTextColor() 的覆盖方法。
MetalThemepublic static ColorUIResource getInactiveControlTextColor()
getCurrentTheme().getInactiveControlTextColor() 的覆盖方法。
MetalThemepublic static ColorUIResource getInactiveSystemTextColor()
getCurrentTheme().getInactiveSystemTextColor() 的覆盖方法。
MetalThemepublic static ColorUIResource getUserTextColor()
getCurrentTheme().getUserTextColor() 的覆盖方法。
MetalThemepublic static ColorUIResource getTextHighlightColor()
getCurrentTheme().getTextHighlightColor() 的覆盖方法。
MetalThemepublic static ColorUIResource getHighlightedTextColor()
getCurrentTheme().getHighlightedTextColor() 的覆盖方法。
MetalThemepublic static ColorUIResource getWindowBackground()
getCurrentTheme().getWindowBackground() 的覆盖方法。
MetalThemepublic static ColorUIResource getWindowTitleBackground()
getCurrentTheme().getWindowTitleBackground() 的覆盖方法。
MetalThemepublic static ColorUIResource getWindowTitleForeground()
getCurrentTheme().getWindowTitleForeground() 的覆盖方法。
MetalThemepublic static ColorUIResource getWindowTitleInactiveBackground()
getCurrentTheme().getWindowTitleInactiveBackground() 的覆盖方法。
MetalThemepublic static ColorUIResource getWindowTitleInactiveForeground()
getCurrentTheme().getWindowTitleInactiveForeground() 的覆盖方法。
MetalThemepublic static ColorUIResource getMenuBackground()
getCurrentTheme().getMenuBackground() 的覆盖方法。
MetalThemepublic static ColorUIResource getMenuForeground()
getCurrentTheme().getMenuForeground() 的覆盖方法。
MetalThemepublic static ColorUIResource getMenuSelectedBackground()
getCurrentTheme().getMenuSelectedBackground() 的覆盖方法。
MetalThemepublic static ColorUIResource getMenuSelectedForeground()
getCurrentTheme().getMenuSelectedForeground() 的覆盖方法。
MetalThemepublic static ColorUIResource getMenuDisabledForeground()
getCurrentTheme().getMenuDisabledForeground() 的覆盖方法。
MetalThemepublic static ColorUIResource getSeparatorBackground()
getCurrentTheme().getSeparatorBackground() 的覆盖方法。
MetalThemepublic static ColorUIResource getSeparatorForeground()
getCurrentTheme().getSeparatorForeground() 的覆盖方法。
MetalThemepublic static ColorUIResource getAcceleratorForeground()
getCurrentTheme().getAcceleratorForeground() 的覆盖方法。
MetalThemepublic static ColorUIResource getAcceleratorSelectedForeground()
getCurrentTheme().getAcceleratorSelectedForeground() 的覆盖方法。
MetalThemepublic LayoutStyle getLayoutStyle()
LayoutStyle,它实现 http://java.sun.com/products/jlf/ed2/book/HIG.Visual2.html 中指定的 Java 外观设计原则。
LookAndFeel 中的 getLayoutStyleLayoutStyle.getInstance()
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。