模块 java.desktop

类 MetalLookAndFeel

所有已实现的接口:
Serializable

public class MetalLookAndFeel extends BasicLookAndFeel
Java 外观,也称为 Metal。

MetalLookAndFeel 提供的每个 ComponentUI 都从默认表派生其行为。除非另有说明,否则此包中的每个 ComponentUI 实现都记录了它们使用的默认值集。除非另有说明,否则会在调用 installUI 时安装默认值,并按照 LookAndFeel 中概述的建议安装默认值。

MetalLookAndFeelMetalTheme 派生它的调色板和字体。默认主题是 OceanTheme 。可以使用setCurrentTheme方法更改主题,有关更改主题的详细信息,请参阅它。在 1.5 之前,默认主题是 DefaultMetalTheme 。系统属性 "swing.metalTheme" 可以设置为 "steel" 以指示默认值应为 DefaultMetalTheme

Warning: 此类的序列化对象将与未来的 Swing 版本不兼容。当前的序列化支持适用于运行相同版本 Swing 的应用程序之间的短期存储或 RMI。从 1.4 开始,对所有 JavaBeans 的长期存储的支持已添加到 java.beans 包中。请参阅 XMLEncoder

参见:
  • 构造方法详细信息

    • MetalLookAndFeel

      public MetalLookAndFeel()
      构造一个 MetalLookAndFeel
  • 方法详情

    • getName

      public String  getName()
      返回此外观的名称。这将返回 "Metal"
      指定者:
      getName 在类 LookAndFeel
      返回:
      这种外观的名称
    • getID

      public String  getID()
      返回此外观的标识符。这将返回 "Metal"
      指定者:
      getID 在类 LookAndFeel
      返回:
      此外观的标识符
    • getDescription

      public String  getDescription()
      返回此外观的简短描述。这将返回 "The Java(tm) Look and Feel"
      指定者:
      getDescription 在类 LookAndFeel
      返回:
      外观的简短描述
    • isNativeLookAndFeel

      public boolean isNativeLookAndFeel()
      返回 falseMetalLookAndFeel 不是本机外观。
      指定者:
      isNativeLookAndFeel 在类 LookAndFeel
      返回:
      false
    • isSupportedLookAndFeel

      public boolean isSupportedLookAndFeel()
      返回 trueMetalLookAndFeel 可以在任何平台上运行。
      指定者:
      isSupportedLookAndFeel 在类 LookAndFeel
      返回:
      true
      参见:
    • getSupportsWindowDecorations

      public boolean getSupportsWindowDecorations()
      返回 true ;金属可以提供Window装饰品。
      重写:
      getSupportsWindowDecorations 在类 LookAndFeel
      返回:
      true
      自从:
      1.4
      参见:
    • initClassDefaults

      protected void initClassDefaults(UIDefaults  table)
      使用从 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 - 如果 tablenull
      参见:
    • initSystemColorDefaults

      protected void initSystemColorDefaults(UIDefaults  table)
      使用系统颜色填充 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 - 如果 tablenull
      参见:
    • initComponentDefaults

      protected void initComponentDefaults(UIDefaults  table)
      使用金属的默认值填充 table
      重写:
      initComponentDefaults 在类 BasicLookAndFeel
      参数:
      table - 要将值添加到的 UIDefaults
      抛出:
      NullPointerException - 如果 tablenull
    • createDefaultTheme

      protected void createDefaultTheme()
      确保当前的 MetalThemenon-null。这是 getCurrentTheme 的覆盖方法。
      参见:
    • getDefaults

      public UIDefaults  getDefaults()
      返回外观默认值。这将依次调用 createDefaultTheme()super.getDefaults()getCurrentTheme().addCustomEntriesToTable(table)

      虽然此方法是公共的,但只有当外观设置为当前外观时以及调用 initialize 后,它才应由 UIManager 调用。

      重写:
      getDefaults 在类 BasicLookAndFeel
      返回:
      外观默认
      参见:
    • provideErrorFeedback

      public void provideErrorFeedback(Component  component)
      当用户尝试无效操作时调用,例如粘贴到具有焦点的不可编辑的 JTextField 中。默认实现发出蜂鸣声。希望不同行为的子类应该覆盖它并提供额外的反馈。
      重写:
      provideErrorFeedback 在类 LookAndFeel
      参数:
      component - Component 错误发生在,可能是 null 指示错误条件与 Component 没有直接关联
      自从:
      1.4
    • setCurrentTheme

      public static void setCurrentTheme(MetalTheme  theme)
      设置 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 - 如果 themenull
      参见:
    • getCurrentTheme

      public static MetalTheme  getCurrentTheme()
      返回 MetalLookAndFeel 当前使用的主题。如果当前主题是 null ,则创建默认主题。
      返回:
      当前主题
      自从:
      1.5
      参见:
    • getDisabledIcon

      public Icon  getDisabledIcon(JComponent  component, Icon  icon)
      返回具有禁用外观的 Icon。此方法用于在未指定时生成禁用的Icon。例如,如果您创建一个 JButton 并且仅通过 setIcon 指定一个 Icon 将调用此方法来生成禁用的 Icon 。如果 null 作为 icon 传递,则此方法返回 null。

      某些外观可能不会呈现禁用的图标,在这种情况下,它们将忽略它。

      重写:
      getDisabledIcon 在类 LookAndFeel
      参数:
      component - 将显示图标的 JComponent,可能为 null
      icon - 从中生成禁用图标的图标。
      返回:
      禁用图标,如果无法生成合适的图标,则为 null。
      自从:
      1.5
    • getDisabledSelectedIcon

      public Icon  getDisabledSelectedIcon(JComponent  component, Icon  icon)
      返回一个 Icon 供同时被选中的禁用组件使用。此方法用于为同时处于禁用和选中状态但没有针对此状态的特定 Icon 的组件生成 Icon。例如,如果您创建一个 JButton 并且仅通过 setIcon 指定一个 Icon,则将调用此方法来生成禁用和选定的 Icon。如果 null 作为 icon 传递,则此方法返回 null。

      某些外观可能不会呈现禁用和选定的图标,在这种情况下,它们将忽略这一点。

      重写:
      getDisabledSelectedIcon 在类 LookAndFeel
      参数:
      component - 将显示图标的 JComponent,可能为 null
      icon - 从中生成禁用和选定图标的图标。
      返回:
      Disabled 和 Selected 图标,如果无法生成合适的图标,则为 null。
      自从:
      1.5
    • getControlTextFont

      public static FontUIResource  getControlTextFont()
      返回当前主题的控制文本字体。这是 getCurrentTheme().getControlTextColor() 的覆盖方法。
      返回:
      控制文本字体
      参见:
    • getSystemTextFont

      public static FontUIResource  getSystemTextFont()
      返回当前主题的系统文本字体。这是 getCurrentTheme().getSystemTextFont() 的覆盖方法。
      返回:
      系统文字字体
      参见:
    • getUserTextFont

      public static FontUIResource  getUserTextFont()
      返回当前主题的用户文本字体。这是 getCurrentTheme().getUserTextFont() 的覆盖方法。
      返回:
      用户文字字体
      参见:
    • getMenuTextFont

      public static FontUIResource  getMenuTextFont()
      返回当前主题的菜单文本字体。这是 getCurrentTheme().getMenuTextFont() 的覆盖方法。
      返回:
      菜单文字字体
      参见:
    • getWindowTitleFont

      public static FontUIResource  getWindowTitleFont()
      返回当前主题的窗口标题字体。这是 getCurrentTheme().getWindowTitleFont() 的覆盖方法。
      返回:
      窗口标题字体
      参见:
    • getSubTextFont

      public static FontUIResource  getSubTextFont()
      返回当前主题的子文本字体。这是 getCurrentTheme().getSubTextFont() 的覆盖方法。
      返回:
      子文本字体
      参见:
    • getDesktopColor

      public static ColorUIResource  getDesktopColor()
      返回当前主题的桌面颜色。这是 getCurrentTheme().getDesktopColor() 的覆盖方法。
      返回:
      桌面颜色
      参见:
    • getFocusColor

      public static ColorUIResource  getFocusColor()
      返回当前主题的焦点颜色。这是 getCurrentTheme().getFocusColor() 的覆盖方法。
      返回:
      焦点颜色
      参见:
    • getWhite

      public static ColorUIResource  getWhite()
      返回当前主题的白色。这是 getCurrentTheme().getWhite() 的覆盖方法。
      返回:
      白色
      参见:
    • getBlack

      public static ColorUIResource  getBlack()
      返回当前主题的黑色。这是 getCurrentTheme().getBlack() 的覆盖方法。
      返回:
      黑色
      参见:
    • getControl

      public static ColorUIResource  getControl()
      返回当前主题的控件颜色。这是 getCurrentTheme().getControl() 的覆盖方法。
      返回:
      控制颜色
      参见:
    • getControlShadow

      public static ColorUIResource  getControlShadow()
      返回当前主题的控件阴影颜色。这是 getCurrentTheme().getControlShadow() 的覆盖方法。
      返回:
      控制阴影颜色
      参见:
    • getControlDarkShadow

      public static ColorUIResource  getControlDarkShadow()
      返回当前主题的控件深色阴影颜色。这是 getCurrentTheme().getControlDarkShadow() 的覆盖方法。
      返回:
      控制深色阴影颜色
      参见:
    • getControlInfo

      public static ColorUIResource  getControlInfo()
      返回当前主题的控件信息颜色。这是 getCurrentTheme().getControlInfo() 的覆盖方法。
      返回:
      控制信息颜色
      参见:
    • getControlHighlight

      public static ColorUIResource  getControlHighlight()
      返回当前主题的控件高亮颜色。这是 getCurrentTheme().getControlHighlight() 的覆盖方法。
      返回:
      控件高亮颜色
      参见:
    • getControlDisabled

      public static ColorUIResource  getControlDisabled()
      返回当前主题的控件禁用颜色。这是 getCurrentTheme().getControlDisabled() 的覆盖方法。
      返回:
      控件禁用颜色
      参见:
    • getPrimaryControl

      public static ColorUIResource  getPrimaryControl()
      返回当前主题的主要控件颜色。这是 getCurrentTheme().getPrimaryControl() 的覆盖方法。
      返回:
      主要控制颜色
      参见:
    • getPrimaryControlShadow

      public static ColorUIResource  getPrimaryControlShadow()
      返回当前主题的主要控件阴影颜色。这是 getCurrentTheme().getPrimaryControlShadow() 的覆盖方法。
      返回:
      主要控制阴影颜色
      参见:
    • getPrimaryControlDarkShadow

      public static ColorUIResource  getPrimaryControlDarkShadow()
      返回当前主题的主要控制深色阴影颜色。这是 getCurrentTheme().getPrimaryControlDarkShadow() 的覆盖方法。
      返回:
      主要控制深色阴影颜色
      参见:
    • getPrimaryControlInfo

      public static ColorUIResource  getPrimaryControlInfo()
      返回当前主题的主要控件信息颜色。这是 getCurrentTheme().getPrimaryControlInfo() 的覆盖方法。
      返回:
      主要控制信息颜色
      参见:
    • getPrimaryControlHighlight

      public static ColorUIResource  getPrimaryControlHighlight()
      返回当前主题的主要控件高亮颜色。这是 getCurrentTheme().getPrimaryControlHighlight() 的覆盖方法。
      返回:
      主控件高亮颜色
      参见:
    • getSystemTextColor

      public static ColorUIResource  getSystemTextColor()
      返回当前主题的系统文本颜色。这是 getCurrentTheme().getSystemTextColor() 的覆盖方法。
      返回:
      系统文字颜色
      参见:
    • getControlTextColor

      public static ColorUIResource  getControlTextColor()
      返回当前主题的控件文本颜色。这是 getCurrentTheme().getControlTextColor() 的覆盖方法。
      返回:
      控制文字颜色
      参见:
    • getInactiveControlTextColor

      public static ColorUIResource  getInactiveControlTextColor()
      返回当前主题的非活动控件文本颜色。这是 getCurrentTheme().getInactiveControlTextColor() 的覆盖方法。
      返回:
      非活动控件文本颜色
      参见:
    • getInactiveSystemTextColor

      public static ColorUIResource  getInactiveSystemTextColor()
      返回当前主题的非活动系统文本颜色。这是 getCurrentTheme().getInactiveSystemTextColor() 的覆盖方法。
      返回:
      非活动系统文本颜色
      参见:
    • getUserTextColor

      public static ColorUIResource  getUserTextColor()
      返回当前主题的用户文本颜色。这是 getCurrentTheme().getUserTextColor() 的覆盖方法。
      返回:
      用户文本颜色
      参见:
    • getTextHighlightColor

      public static ColorUIResource  getTextHighlightColor()
      返回当前主题的文本高亮颜色。这是 getCurrentTheme().getTextHighlightColor() 的覆盖方法。
      返回:
      文本高亮颜色
      参见:
    • getHighlightedTextColor

      public static ColorUIResource  getHighlightedTextColor()
      返回当前主题的突出显示文本颜色。这是 getCurrentTheme().getHighlightedTextColor() 的覆盖方法。
      返回:
      突出显示的文本颜色
      参见:
    • getWindowBackground

      public static ColorUIResource  getWindowBackground()
      返回当前主题的窗口背景颜色。这是 getCurrentTheme().getWindowBackground() 的覆盖方法。
      返回:
      窗口背景颜色
      参见:
    • getWindowTitleBackground

      public static ColorUIResource  getWindowTitleBackground()
      返回当前主题的窗口标题背景色。这是 getCurrentTheme().getWindowTitleBackground() 的覆盖方法。
      返回:
      窗口标题背景色
      参见:
    • getWindowTitleForeground

      public static ColorUIResource  getWindowTitleForeground()
      返回当前主题的窗口标题前景色。这是 getCurrentTheme().getWindowTitleForeground() 的覆盖方法。
      返回:
      窗口标题前景色
      参见:
    • getWindowTitleInactiveBackground

      public static ColorUIResource  getWindowTitleInactiveBackground()
      返回当前主题的窗口标题非活动背景色。这是 getCurrentTheme().getWindowTitleInactiveBackground() 的覆盖方法。
      返回:
      窗口标题非活动背景颜色
      参见:
    • getWindowTitleInactiveForeground

      public static ColorUIResource  getWindowTitleInactiveForeground()
      返回当前主题的窗口标题非活动前景色。这是 getCurrentTheme().getWindowTitleInactiveForeground() 的覆盖方法。
      返回:
      窗口标题非活动前景色
      参见:
    • getMenuBackground

      public static ColorUIResource  getMenuBackground()
      返回当前主题的菜单背景色。这是 getCurrentTheme().getMenuBackground() 的覆盖方法。
      返回:
      菜单背景颜色
      参见:
    • getMenuForeground

      public static ColorUIResource  getMenuForeground()
      返回当前主题的菜单前景色。这是 getCurrentTheme().getMenuForeground() 的覆盖方法。
      返回:
      菜单前景色
      参见:
    • getMenuSelectedBackground

      public static ColorUIResource  getMenuSelectedBackground()
      返回当前主题的菜单选择背景颜色。这是 getCurrentTheme().getMenuSelectedBackground() 的覆盖方法。
      返回:
      菜单选择的背景颜色
      参见:
    • getMenuSelectedForeground

      public static ColorUIResource  getMenuSelectedForeground()
      返回菜单选择的当前主题的前景色。这是 getCurrentTheme().getMenuSelectedForeground() 的覆盖方法。
      返回:
      菜单选择前景色
      参见:
    • getMenuDisabledForeground

      public static ColorUIResource  getMenuDisabledForeground()
      返回当前主题的菜单禁用前景色。这是 getCurrentTheme().getMenuDisabledForeground() 的覆盖方法。
      返回:
      菜单禁用前景色
      参见:
    • getSeparatorBackground

      public static ColorUIResource  getSeparatorBackground()
      返回当前主题的分隔符背景色。这是 getCurrentTheme().getSeparatorBackground() 的覆盖方法。
      返回:
      分隔符背景颜色
      参见:
    • getSeparatorForeground

      public static ColorUIResource  getSeparatorForeground()
      返回当前主题的分隔符前景色。这是 getCurrentTheme().getSeparatorForeground() 的覆盖方法。
      返回:
      分隔符前景色
      参见:
    • getAcceleratorForeground

      public static ColorUIResource  getAcceleratorForeground()
      返回当前主题的加速器前景色。这是 getCurrentTheme().getAcceleratorForeground() 的覆盖方法。
      返回:
      分离器加速器前景色
      参见:
    • getAcceleratorSelectedForeground

      public static ColorUIResource  getAcceleratorSelectedForeground()
      返回当前主题的加速器选择的前景色。这是 getCurrentTheme().getAcceleratorSelectedForeground() 的覆盖方法。
      返回:
      加速器选择的前景色
      参见:
    • getLayoutStyle

      public LayoutStyle  getLayoutStyle()
      返回实现 Java 外观设计指南的 LayoutStyle
      重写:
      getLayoutStyle 在类 LookAndFeel
      返回:
      LayoutStyle 实现 Java 外观设计指南
      自从:
      1.6
      参见: