/** * Creates and returns a Highlighter which highlights every second row * background with the given color. The rows between are not highlighted * that is typically, they will show the container's background. * * @param stripeBackground the background color for the striping. * @return a Highlighter striping every second row background. */ public static Highlighter createSimpleStriping(Color stripeBackground) { ColorHighlighter hl = new ColorHighlighter(HighlightPredicate.ODD, stripeBackground, null); return hl; }
/** * applies the memory hack for renderers of type DefaultTableCellRenderer, * does nothing for other types. * @param renderer the component to highlight * @param adapter the renderee's component state. */ @Override public Component highlight(Component renderer, ComponentAdapter adapter) { //JW // table renderers have different state memory as list/tree renderers // without the null they don't unstamp! // but... null has adversory effect on JXList f.i. - selection // color is changed. This is related to #178-swingx: // highlighter background computation is weird. // if (renderer instanceof DefaultTableCellRenderer) { return super.highlight(renderer, adapter); } return renderer; }
/** * {@inheritDoc} */ @Override protected Component doHighlight(Component renderer, ComponentAdapter adapter) { applyBackground(renderer, adapter); applyForeground(renderer, adapter); return renderer; }
/** * Sets the background color of this <code>ColorHighlighter</code> and * notifies registered ChangeListeners. * * @param color the background color of this <code>Highlighter</code>, * or null, to clear any existing background color */ public void setBackground(Color color) { if (areEqual(color, getBackground())) return; background = color; fireStateChanged(); }
/** * Sets the foreground color of this <code>ColorHighlighter</code> and notifies * registered ChangeListeners. * * @param color the foreground color of this <code>ColorHighlighter</code>, * or null, to clear any existing foreground color */ public void setForeground(Color color) { if (areEqual(color, getForeground())) return; foreground = color; fireStateChanged(); }
/** * Sets the selected background color of this <code>ColorHighlighter</code> * and notifies registered ChangeListeners. * * @param color the selected background color of this <code>ColorHighlighter</code>, * or null, to clear any existing selected background color */ public void setSelectedBackground(Color color) { if (areEqual(color, getSelectedBackground()))return; selectedBackground = color; fireStateChanged(); }
/** * Sets the selected foreground color of this <code>ColorHighlighter</code> and * notifies registered ChangeListeners. * * @param color the selected foreground color of this <code>ColorHighlighter</code>, * or null, to clear any existing selected foreground color */ public void setSelectedForeground(Color color) { if (areEqual(color, getSelectedForeground())) return; selectedForeground = color; fireStateChanged(); }
/** * Applies a suitable background for the renderer component within the * specified adapter. <p> * * This implementation applies its background or selectedBackground color * (depending on the adapter's selected state) if != null. * Otherwise it does nothing. * * @param renderer the cell renderer component that is to be decorated * @param adapter the ComponentAdapter for this decorate operation */ protected void applyBackground(Component renderer, ComponentAdapter adapter) { Color color = adapter.isSelected() ? getSelectedBackground() : getBackground(); if (color != null) { renderer.setBackground(color); } } /**
/** * Applies a suitable foreground for the renderer component within the * specified adapter. <p> * * This implementation applies its foreground or selectedfForeground color * (depending on the adapter's selected state) if != null. * Otherwise it does nothing. * * @param renderer the cell renderer component that is to be decorated * @param adapter the ComponentAdapter for this decorate operation */ protected void applyForeground(Component renderer, ComponentAdapter adapter) { Color color = adapter.isSelected() ? getSelectedForeground() : getForeground(); if (color != null) { renderer.setForeground(color); } }
ColorHighlighter grayHighlighter = new ColorHighlighter(new IsCellEditablePredicate(table)); grayHighlighter.setBackground(Color.LIGHT_GRAY); grayHighlighter.setForeground(table.getForeground()); grayHighlighter.setSelectedBackground(table.getSelectionBackground().darker()); grayHighlighter.setSelectedForeground(table.getSelectionForeground().darker()); table.setHighlighters(grayHighlighter);
@Override protected void applyBackground(Component renderer, ComponentAdapter adapter ) { if (adapter.getValue() == null) { super.applyBackground(renderer, adapter); } else { if (adapter.getColumnClass().equals(Boolean.class)) { final boolean value = ((boolean) adapter.getValue()); if (adapter.isSelected()) { if (value) { renderer.setBackground(COLOR_PRESENCE_SELECTED); } else { renderer.setBackground(COLOR_ABSENCE_SELECTED); } } else { if (value) { renderer.setBackground(COLOR_PRESENCE); } else { renderer.setBackground(COLOR_ABSENCE); } } } else { super.applyBackground(renderer, adapter); } } } }
Color tempColor = ((ColorHighlighter) jxTable.getHighlighters()[0]).getBackground();
/** * Sets the background color of this <code>ColorHighlighter</code> and * notifies registered ChangeListeners. * * @param color the background color of this <code>Highlighter</code>, * or null, to clear any existing background color */ public void setBackground(Color color) { if (areEqual(color, getBackground())) return; background = color; fireStateChanged(); }
/** * Sets the foreground color of this <code>ColorHighlighter</code> and notifies * registered ChangeListeners. * * @param color the foreground color of this <code>ColorHighlighter</code>, * or null, to clear any existing foreground color */ public void setForeground(Color color) { if (areEqual(color, getForeground())) return; foreground = color; fireStateChanged(); }
/** * Sets the selected background color of this <code>ColorHighlighter</code> * and notifies registered ChangeListeners. * * @param color the selected background color of this <code>ColorHighlighter</code>, * or null, to clear any existing selected background color */ public void setSelectedBackground(Color color) { if (areEqual(color, getSelectedBackground()))return; selectedBackground = color; fireStateChanged(); }
/** * Sets the selected foreground color of this <code>ColorHighlighter</code> and * notifies registered ChangeListeners. * * @param color the selected foreground color of this <code>ColorHighlighter</code>, * or null, to clear any existing selected foreground color */ public void setSelectedForeground(Color color) { if (areEqual(color, getSelectedForeground())) return; selectedForeground = color; fireStateChanged(); } }
/** * Applies a suitable background for the renderer component within the * specified adapter. <p> * * This implementation applies its background or selectedBackground color * (depending on the adapter's selected state) if != null. * Otherwise it does nothing. * * @param renderer the cell renderer component that is to be decorated * @param adapter the ComponentAdapter for this decorate operation */ protected void applyBackground(Component renderer, ComponentAdapter adapter) { Color color = adapter.isSelected() ? getSelectedBackground() : getBackground(); renderer.setBackground(blend(renderer.getBackground(), color)); }
/** * Applies a suitable foreground for the renderer component within the * specified adapter. <p> * * This implementation applies its foreground or selectedfForeground color * (depending on the adapter's selected state) if != null. * Otherwise it does nothing. * * @param renderer the cell renderer component that is to be decorated * @param adapter the ComponentAdapter for this decorate operation */ protected void applyForeground(Component renderer, ComponentAdapter adapter) { Color color = adapter.isSelected() ? getSelectedForeground() : getForeground(); renderer.setForeground(blend(renderer.getForeground(), color)); }
@Override protected void applyBackground(Component renderer, ComponentAdapter adapter ) { super.applyBackground(renderer, adapter); int columnIndex = adapter.convertColumnIndexToModel(adapter.column); if (this.tableModel.isFirstSampleColumn(columnIndex) && renderer instanceof JComponent ) { ((JComponent) renderer) .setBorder(createMatteBorder(0, borderSize, 0, 0, BLACK)); } } }
public InternalHighlighter() { _normalHighlighter = new ColorHighlighter(WidgetUtils.BG_COLOR_BRIGHTEST, WidgetUtils.BG_COLOR_DARKEST, WidgetUtils.BG_COLOR_BRIGHTEST, WidgetUtils.BG_COLOR_DARKEST); _filledHighlighter = new ColorHighlighter(WidgetUtils.BG_COLOR_BRIGHTEST, WidgetUtils.BG_COLOR_BLUE_DARK, WidgetUtils.BG_COLOR_BRIGHTEST, WidgetUtils.BG_COLOR_BLUE_DARK); _blankHighlighter = new ColorHighlighter(WidgetUtils.BG_COLOR_BRIGHT, WidgetUtils.ADDITIONAL_COLOR_RED_BRIGHT, WidgetUtils.BG_COLOR_BRIGHT, WidgetUtils.ADDITIONAL_COLOR_RED_BRIGHT); _nullHighlighter = new ColorHighlighter(WidgetUtils.BG_COLOR_BRIGHT, WidgetUtils.ADDITIONAL_COLOR_PURPLE_BRIGHT, WidgetUtils.BG_COLOR_BRIGHT, WidgetUtils.ADDITIONAL_COLOR_PURPLE_BRIGHT); }