public class ColorType extends Object
每个SynthStyle
有一组ColorType
s,可以通过SynthStyle.getColor(SynthContext, ColorType)
方法访问。 SynthStyle
的installDefaults
将安装FOREGROUND
颜色作为组件的前景,并将BACKGROUND
颜色安装到组件的背景(假设您尚未明确指定前景色和背景颜色)。 一些组件支持多个基于色彩特性,例如JList
具有属性selectionForeground
,其将被映射到FOREGROUND
用的组分状态SynthConstants.SELECTED
。
以下示例显示一个自定义的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;
}
}
Modifier and Type | Field and Description |
---|---|
static ColorType |
BACKGROUND
ColorType为区域的背景。
|
static ColorType |
FOCUS
ColorType为焦点。
|
static ColorType |
FOREGROUND
ColorType为区域的前景。
|
static int |
MAX_COUNT
最大数量
ColorType 秒。
|
static ColorType |
TEXT_BACKGROUND
ColorType为区域的背景。
|
static ColorType |
TEXT_FOREGROUND
ColorType为区域的前景。
|
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
s。
protected ColorType(String description)
description
- ColorType的字符串描述。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.