Пример #1
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;
  }
Пример #2
0
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   String str = Objects.toString(value, "");
   if (highlighter.isHighlightableCell(row, column)) {
     setText("<html><u>" + str);
     setForeground(isSelected ? table.getSelectionForeground() : HIGHLIGHT);
     setBackground(isSelected ? table.getSelectionBackground().darker() : table.getBackground());
   } else {
     setText(str);
     setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
     setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
   }
   return this;
 }