下面列出了javax.swing.plaf.synth.ColorType#TEXT_BACKGROUND 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* {@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;
}
/**
* 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;
}
@Override
public Object[] createLookAndFeelCustomizationKeysAndValues() {
if (ThemeValue.functioning()) {
return new Object[] {
//XXX once the JDK team has integrated support for standard
//UIManager keys into 1.5 (not there as of b47), these can
//probably be deleted, resulting in a performance improvement:
"control", control,
"controlHighlight", new ThemeValue (Region.PANEL, ThemeValue.LIGHT, Color.LIGHT_GRAY), //NOI18N
"controlShadow", new ThemeValue (Region.PANEL, ThemeValue.DARK, Color.DARK_GRAY), //NOI18N
"controlDkShadow", new ThemeValue (Region.PANEL, ThemeValue.BLACK, Color.BLACK), //NOI18N
"controlLtHighlight", new ThemeValue (Region.PANEL, ThemeValue.WHITE, Color.WHITE), //NOI18N
"textText", new ThemeValue (Region.PANEL, ColorType.TEXT_FOREGROUND, Color.BLACK), //NOI18N
"text", new ThemeValue (Region.PANEL, ColorType.TEXT_BACKGROUND, Color.GRAY), //NOI18N
"tab_unsel_fill", control, //NOI18N
"SplitPane.dividerSize", new Integer (2), //NOI18N
SYSTEMFONT, controlFont, //NOI18N
USERFONT, controlFont, //NOI18N
MENUFONT, controlFont, //NOI18N
LISTFONT, controlFont, //NOI18N
"Label.font", controlFont, //NOI18N
"Panel.font", controlFont, //NOI18N
// workaround: GTKLookAndFeel FileChooser is unusable, cannot
// choose a dir and doesn't look native anyway. We force MetalFileChooserUI
"FileChooserUI", "javax.swing.plaf.metal.MetalFileChooserUI", // NOI18N
"FileView.computerIcon", javax.swing.plaf.metal.MetalIconFactory.getTreeComputerIcon(), // NOI18N
"FileView.hardDriveIcon", javax.swing.plaf.metal.MetalIconFactory.getTreeHardDriveIcon(), // NOI18N
"FileView.floppyDriveIcon", javax.swing.plaf.metal.MetalIconFactory.getTreeFloppyDriveIcon(), // NOI18N
"FileChooser.newFolderIcon", javax.swing.plaf.metal.MetalIconFactory.getFileChooserNewFolderIcon(), // NOI18N
"FileChooser.upFolderIcon", javax.swing.plaf.metal.MetalIconFactory.getFileChooserUpFolderIcon(), // NOI18N
"FileChooser.homeFolderIcon", javax.swing.plaf.metal.MetalIconFactory.getFileChooserHomeFolderIcon(), // NOI18N
"FileChooser.detailsViewIcon", javax.swing.plaf.metal.MetalIconFactory.getFileChooserDetailViewIcon(), // NOI18N
"FileChooser.listViewIcon", javax.swing.plaf.metal.MetalIconFactory.getFileChooserListViewIcon(), // NOI18N
"FileChooser.usesSingleFilePane", Boolean.TRUE, // NOI18N
"FileChooser.ancestorInputMap", // NOI18N
new UIDefaults.LazyInputMap(new Object[] {
"ESCAPE", "cancelSelection", // NOI18N
"F2", "editFileName", // NOI18N
"F5", "refresh", // NOI18N
"BACK_SPACE", "Go Up", // NOI18N
"ENTER", "approveSelection", // NOI18N
"ctrl ENTER", "approveSelection" // NOI18N
}),
// special tree icons - only for property sheet
"Tree.gtk_expandedIcon", new GTKExpandedIcon(),
"Tree.gtk_collapsedIcon", new GTKCollapsedIcon(),
};
} else {
Object[] result = new Object[] {
TOOLBAR_UI, new UIDefaults.ProxyLazyValue("org.netbeans.swing.plaf.gtk.GtkToolbarUI"), //NOI18N
// special tree icons - only for property sheet
"Tree.gtk_expandedIcon", new GTKExpandedIcon(),
"Tree.gtk_collapsedIcon", new GTKCollapsedIcon(),
};
return result;
}
}