本文整理汇总了Java中javax.swing.plaf.synth.ColorType.BACKGROUND属性的典型用法代码示例。如果您正苦于以下问题:Java ColorType.BACKGROUND属性的具体用法?Java ColorType.BACKGROUND怎么用?Java ColorType.BACKGROUND使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.swing.plaf.synth.ColorType
的用法示例。
在下文中一共展示了ColorType.BACKGROUND属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColorForState
/**
* {@inheritDoc}
*
* <p>Overridden to cause this style to populate itself with data from
* UIDefaults, if necessary.</p>
*
* <p>In addition, NimbusStyle handles ColorTypes slightly differently from
* Synth.</p>
* <ul>
* <li>ColorType.BACKGROUND will equate to the color stored in UIDefaults
* named "background".</li>
* <li>ColorType.TEXT_BACKGROUND will equate to the color stored in
* UIDefaults named "textBackground".</li>
* <li>ColorType.FOREGROUND will equate to the color stored in UIDefaults
* named "textForeground".</li>
* <li>ColorType.TEXT_FOREGROUND will equate to the color stored in
* UIDefaults named "textForeground".</li>
* </ul>
*/
@Override protected Color getColorForState(SynthContext ctx, ColorType type) {
String key = null;
if (type == ColorType.BACKGROUND) {
key = "background";
} else if (type == ColorType.FOREGROUND) {
//map FOREGROUND as TEXT_FOREGROUND
key = "textForeground";
} else if (type == ColorType.TEXT_BACKGROUND) {
key = "textBackground";
} else if (type == ColorType.TEXT_FOREGROUND) {
key = "textForeground";
} else if (type == ColorType.FOCUS) {
key = "focus";
} else if (type != null) {
key = type.toString();
} else {
return DEFAULT_COLOR;
}
Color c = (Color) get(ctx, key);
//if all else fails, return a default color (which is a ColorUIResource)
if (c == null) c = DEFAULT_COLOR;
return c;
}
示例2: getColorForState
/**
* @inheritDoc
*
* <p>Overridden to cause this style to populate itself with data from
* UIDefaults, if necessary.</p>
*
* <p>In addition, NimbusStyle handles ColorTypes slightly differently from
* Synth.</p>
* <ul>
* <li>ColorType.BACKGROUND will equate to the color stored in UIDefaults
* named "background".</li>
* <li>ColorType.TEXT_BACKGROUND will equate to the color stored in
* UIDefaults named "textBackground".</li>
* <li>ColorType.FOREGROUND will equate to the color stored in UIDefaults
* named "textForeground".</li>
* <li>ColorType.TEXT_FOREGROUND will equate to the color stored in
* UIDefaults named "textForeground".</li>
* </ul>
*/
@Override protected Color getColorForState(SynthContext ctx, ColorType type) {
String key = null;
if (type == ColorType.BACKGROUND) {
key = "background";
} else if (type == ColorType.FOREGROUND) {
//map FOREGROUND as TEXT_FOREGROUND
key = "textForeground";
} else if (type == ColorType.TEXT_BACKGROUND) {
key = "textBackground";
} else if (type == ColorType.TEXT_FOREGROUND) {
key = "textForeground";
} else if (type == ColorType.FOCUS) {
key = "focus";
} else if (type != null) {
key = type.toString();
} else {
return DEFAULT_COLOR;
}
Color c = (Color) get(ctx, key);
//if all else fails, return a default color (which is a ColorUIResource)
if (c == null) c = DEFAULT_COLOR;
return c;
}
示例3: getColorForState
/**
* @InheritDoc
*
* <p>Overridden to cause this style to populate itself with data from
* UIDefaults, if necessary.</p>
*
* <p>In addition, NimbusStyle handles ColorTypes slightly differently from
* Synth.</p>
* <ul>
* <li>ColorType.BACKGROUND will equate to the color stored in UIDefaults
* named "background".</li>
* <li>ColorType.TEXT_BACKGROUND will equate to the color stored in
* UIDefaults named "textBackground".</li>
* <li>ColorType.FOREGROUND will equate to the color stored in UIDefaults
* named "textForeground".</li>
* <li>ColorType.TEXT_FOREGROUND will equate to the color stored in
* UIDefaults named "textForeground".</li>
* </ul>
*/
@Override protected Color getColorForState(SynthContext ctx, ColorType type) {
String key;
if (type == ColorType.BACKGROUND) {
key = "background";
} else if (type == ColorType.FOREGROUND) {
//map FOREGROUND as TEXT_FOREGROUND
key = "textForeground";
} else if (type == ColorType.TEXT_BACKGROUND) {
key = "textBackground";
} else if (type == ColorType.TEXT_FOREGROUND) {
key = "textForeground";
} else if (type == ColorType.FOCUS) {
key = "focus";
} else if (type != null) {
key = type.toString();
} else {
return DEFAULT_COLOR;
}
Color c = (Color) get(ctx, key);
//if all else fails, return a default color (which is a ColorUIResource)
if (c == null) c = DEFAULT_COLOR;
return c;
}
示例4: getColorForState
/**
* Returns the color for the specified state. This should NOT call any
* methods on the <code>JComponent</code>.
*
* <p>Overridden to cause this style to populate itself with data from
* UIDefaults, if necessary.</p>
*
* <p>In addition, SeaGlassStyle handles ColorTypes slightly differently
* from Synth.</p>
*
* <ul>
* <li>ColorType.BACKGROUND will equate to the color stored in UIDefaults
* named "background".</li>
* <li>ColorType.TEXT_BACKGROUND will equate to the color stored in
* UIDefaults named "textBackground".</li>
* <li>ColorType.FOREGROUND will equate to the color stored in UIDefaults
* named "textForeground".</li>
* <li>ColorType.TEXT_FOREGROUND will equate to the color stored in
* UIDefaults named "textForeground".</li>
* </ul>
*
* @param ctx context SynthContext identifying requester
* @param type Type of color being requested.
*
* @return Color to render with
*/
@Override
public Color getColorForState(SynthContext ctx, ColorType type) {
String key = null;
if (type == ColorType.BACKGROUND) {
key = "background";
} else if (type == ColorType.FOREGROUND) {
// map FOREGROUND as TEXT_FOREGROUND
key = "textForeground";
} else if (type == ColorType.TEXT_BACKGROUND) {
key = "textBackground";
} else if (type == ColorType.TEXT_FOREGROUND) {
key = "textForeground";
} else if (type == ColorType.FOCUS) {
key = "focus";
} else if (type != null) {
key = type.toString();
} else {
return defaultColor;
}
Color c = (Color) get(ctx, key);
// if all else fails, return a default color (which is a
// ColorUIResource)
if (c == null)
c = defaultColor;
return c;
}