* @param context the SeaGlassContext.
* @param prefix the control prefix, e.g. "TextField",
* "FormattedTextField", or "PasswordField".
*/
static void updateStyle(JTextComponent c, SeaGlassContext context, String prefix) {
SeaGlassStyle style = (SeaGlassStyle) context.getStyle();
Color color = c.getCaretColor();
if (color == null || color instanceof UIResource) {
c.setCaretColor((Color) style.get(context, prefix + ".caretForeground"));
}
Color fg = c.getForeground();
if (fg == null || fg instanceof UIResource) {
fg = style.getColorForState(context, ColorType.TEXT_FOREGROUND);
if (fg != null) {
c.setForeground(fg);
}
}
Object ar = style.get(context, prefix + ".caretAspectRatio");
if (ar instanceof Number) {
c.putClientProperty("caretAspectRatio", ar);
}
context.setComponentState(SELECTED | FOCUSED);
Color s = c.getSelectionColor();
if (s == null || s instanceof UIResource) {
c.setSelectionColor(style.getColor(context, ColorType.TEXT_BACKGROUND));
}
Color sfg = c.getSelectedTextColor();
if (sfg == null || sfg instanceof UIResource) {
c.setSelectedTextColor(style.getColor(context, ColorType.TEXT_FOREGROUND));
}
context.setComponentState(DISABLED);
Color dfg = c.getDisabledTextColor();
if (dfg == null || dfg instanceof UIResource) {
c.setDisabledTextColor(style.getColor(context, ColorType.TEXT_FOREGROUND));
}
Insets margin = c.getMargin();
if (margin == null || margin instanceof UIResource) {
margin = (Insets) style.get(context, prefix + ".margin");
if (margin == null) {
// Some places assume margins are non-null.
margin = SeaGlassLookAndFeel.EMPTY_UIRESOURCE_INSETS;
}
c.setMargin(margin);
}
Caret caret = c.getCaret();
if (caret instanceof UIResource) {
Object o = style.get(context, prefix + ".caretBlinkRate");
if (o != null && o instanceof Integer) {
Integer rate = (Integer) o;
caret.setBlinkRate(rate.intValue());