static void updateStyle(JTextComponent comp, SynthContext context, String prefix) { SynthStyle style = context.getStyle(); Color color = comp.getCaretColor(); if (color == null || color instanceof UIResource) { comp.setCaretColor((Color) style.get(context, prefix + ".caretForeground")); } Color fg = comp.getForeground(); if (fg == null || fg instanceof UIResource) { fg = style.getColorForState(context, ColorType.TEXT_FOREGROUND); if (fg != null) { comp.setForeground(fg); } } Object ar = style.get(context, prefix + ".caretAspectRatio"); if (ar instanceof Number) { comp.putClientProperty("caretAspectRatio", ar); } context.setComponentState(SELECTED | FOCUSED); Color s = comp.getSelectionColor(); if (s == null || s instanceof UIResource) { comp.setSelectionColor(style.getColor(context, ColorType.TEXT_BACKGROUND)); } Color sfg = comp.getSelectedTextColor(); if (sfg == null || sfg instanceof UIResource) { comp.setSelectedTextColor(style.getColor(context, ColorType.TEXT_FOREGROUND)); } context.setComponentState(DISABLED); Color dfg = comp.getDisabledTextColor(); if (dfg == null || dfg instanceof UIResource) { comp.setDisabledTextColor(style.getColor(context, ColorType.TEXT_FOREGROUND)); } Insets margin = comp.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 = SynthLookAndFeel.EMPTY_UIRESOURCE_INSETS; } comp.setMargin(margin); } Caret caret = comp.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()); } } }
private void updateStyle(JTable c) { SynthContext context = getContext(c, ENABLED); SynthStyle oldStyle = style; style = SynthLookAndFeel.updateStyle(context, this); if (style != oldStyle) { context.setComponentState(ENABLED | SELECTED); Color sbg = table.getSelectionBackground(); if (sbg == null || sbg instanceof UIResource) { table.setSelectionBackground(style.getColor(context, ColorType.TEXT_BACKGROUND)); } Color sfg = table.getSelectionForeground(); if (sfg == null || sfg instanceof UIResource) { table.setSelectionForeground(style.getColor(context, ColorType.TEXT_FOREGROUND)); } context.setComponentState(ENABLED); Color gridColor = table.getGridColor(); if (gridColor == null || gridColor instanceof UIResource) { gridColor = (Color) style.get(context, "Table.gridColor"); if (gridColor == null) { gridColor = style.getColor(context, ColorType.FOREGROUND); } table.setGridColor(gridColor == null ? new ColorUIResource(Color.GRAY) : gridColor); } useTableColors = style.getBoolean(context, "Table.rendererUseTableColors", true); useUIBorder = style.getBoolean(context, "Table.rendererUseUIBorder", true); Object rowHeight = style.get(context, "Table.rowHeight"); if (rowHeight != null) { LookAndFeel.installProperty(table, "rowHeight", rowHeight); } boolean showGrid = style.getBoolean(context, "Table.showGrid", true); if (!showGrid) { table.setShowGrid(false); } Dimension d = table.getIntercellSpacing(); // if (d == null || d instanceof UIResource) { if (d != null) { d = (Dimension) style.get(context, "Table.intercellSpacing"); } alternateColor = (Color) style.get(context, "Table.alternateRowColor"); if (d != null) { table.setIntercellSpacing(d); } if (oldStyle != null) { uninstallKeyboardActions(); installKeyboardActions(); } } context.dispose(); }
private void updateStyle(JComponent c) { SynthContext context = getContext(list, ENABLED); SynthStyle oldStyle = style; style = SynthLookAndFeel.updateStyle(context, this); if (style != oldStyle) { context.setComponentState(SELECTED); Color sbg = list.getSelectionBackground(); if (sbg == null || sbg instanceof UIResource) { list.setSelectionBackground(style.getColor(context, ColorType.TEXT_BACKGROUND)); } Color sfg = list.getSelectionForeground(); if (sfg == null || sfg instanceof UIResource) { list.setSelectionForeground(style.getColor(context, ColorType.TEXT_FOREGROUND)); } useListColors = style.getBoolean(context, "List.rendererUseListColors", true); useUIBorder = style.getBoolean(context, "List.rendererUseUIBorder", true); int height = style.getInt(context, "List.cellHeight", -1); if (height != -1) { list.setFixedCellHeight(height); } if (oldStyle != null) { uninstallKeyboardActions(); installKeyboardActions(); } } context.dispose(); }
private void paintDragDivider(Graphics g, int x, int y, int w, int h) { SynthContext context = getContext(splitPane, Region.SPLIT_PANE_DIVIDER); context.setComponentState(((context.getComponentState() | MOUSE_OVER) ^ MOUSE_OVER) | PRESSED); Shape oldClip = g.getClip(); g.clipRect(x, y, w, h); context .getPainter() .paintSplitPaneDragDivider(context, g, x, y, w, h, splitPane.getOrientation()); g.setClip(oldClip); context.dispose(); }