|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjavax.swing.plaf.synth.ColorType
public class ColorType
可从某种风格中获取的一些颜色的类型安全枚举。
每个 SynthStyle 都有一组 ColorType,可以使用 SynthStyle.getColor(SynthContext, ColorType) 方法来访问它们。SynthStyle 的 installDefaults 将安装 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;
}
}
| 字段摘要 | |
|---|---|
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 |
| 字段详细信息 |
|---|
public static final ColorType FOREGROUND
public static final ColorType BACKGROUND
public static final ColorType TEXT_FOREGROUND
public static final ColorType TEXT_BACKGROUND
public static final ColorType FOCUS
public static final int MAX_COUNT
ColorType 数。
| 构造方法详细信息 |
|---|
protected ColorType(String description)
description - ColorType 的字符串描述。| 方法详细信息 |
|---|
public final int getID()
public String toString()
ColorType 的文本描述。
返回值就是用来创建 ColorType 的那个值。
Object 中的 toString
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。