JavaTM Platform
Standard Ed. 6

javax.swing.plaf.synth
类 ColorType

java.lang.Object
  继承者 javax.swing.plaf.synth.ColorType

public class ColorType
     
extends Object

可从某种风格中获取的一些颜色的类型安全枚举。

每个 SynthStyle 都有一组 ColorType,可以使用 SynthStyle.getColor(SynthContext, ColorType) 方法来访问它们。SynthStyleinstallDefaults 将安装 FOREGROUND 颜色作为 Component 的前景色,并安装 BACKGROUND 颜色作为组件的背景色(假定您没有显式指定前景色和背景色)。一些组件支持更多基于颜色的属性,例如,JList 拥有属性 selectionForeground,该属性将在组件状态为 SynthConstants.SELECTED 的情况下被映射到 FOREGROUND

以下示例显示了一个自定义 SynthStyle,对于 DISABLED 状态,它返回红色,其他情况返回黑色。

 class MyStyle extends SynthStyle {
     private Color disabledColor = new ColorUIResource(Color.RED);
     private Color color = new ColorUIResource(Color.BLACK);
     protected Color getColorForState(SynthContext context, ColorType type){
         if (context.getComponentState() == SynthConstants.DISABLED) {
             return disabledColor;
         }
         return color;
     }
 }
 

从以下版本开始:
1.5

字段摘要
static ColorType BACKGROUND
          某一 region 背景的 ColorType。
static ColorType FOCUS
          焦点的 ColorType。
static ColorType FOREGROUND
          某一 region 前景的 ColorType。
static int MAX_COUNT
          最大 ColorType 数。
static ColorType TEXT_BACKGROUND
          某一 region 背景的 ColorType。
static ColorType TEXT_FOREGROUND
          某一 region 前景的 ColorType。
 
构造方法摘要
protected ColorType(String description)
          创建一个具有指定描述的 ColorType。
 
方法摘要
 int getID()
          以整数形式返回此 ColorType 的唯一 id。
 String toString()
          返回此 ColorType 的文本描述。
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

FOREGROUND

public static final ColorType FOREGROUND
某一 region 前景的 ColorType。


BACKGROUND

public static final ColorType BACKGROUND
某一 region 背景的 ColorType。


TEXT_FOREGROUND

public static final ColorType TEXT_FOREGROUND
某一 region 前景的 ColorType。


TEXT_BACKGROUND

public static final ColorType TEXT_BACKGROUND
某一 region 背景的 ColorType。


FOCUS

public static final ColorType FOCUS
焦点的 ColorType。


MAX_COUNT

public static final int MAX_COUNT
最大 ColorType 数。

构造方法详细信息

ColorType

protected ColorType(String description)
创建一个具有指定描述的 ColorType。

参数:
description - ColorType 的字符串描述。
方法详细信息

getID

public final int getID()
以整数形式返回此 ColorType 的唯一 id。

返回:
以整数形式返回此 ColorType 的唯一 id。

toString

public String toString()
返回此 ColorType 的文本描述。 返回值就是用来创建 ColorType 的那个值。

覆盖:
Object 中的 toString
返回:
字符串的描述。

JavaTM Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策