示例#1
0
 @Override
 public Component prepareEditor(TableCellEditor editor, int row, int column) {
   Component c = super.prepareEditor(editor, row, column);
   if (c instanceof JCheckBox) {
     ((JCheckBox) c).setBackground(getSelectionBackground());
   }
   return c;
 }
示例#2
0
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    getModel().setRollover(highlighter.isHighlightableCell(row, column));

    if (isSelected) {
      setForeground(table.getSelectionForeground());
      super.setBackground(table.getSelectionBackground());
    } else {
      setForeground(table.getForeground());
      setBackground(table.getBackground());
      // setBackground(row % 2 == 0 ? table.getBackground() : Color.WHITE); //Nimbus
    }
    setSelected(Objects.equals(value, Boolean.TRUE));
    return this;
  }