示例#1
0
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    textLabel.setFont(table.getFont());
    textLabel.setText(Objects.toString(value, ""));
    textLabel.setBorder(hasFocus ? focusCellHighlightBorder : noFocusBorder);

    FontMetrics fm = table.getFontMetrics(table.getFont());
    Insets i = textLabel.getInsets();
    int swidth =
        iconLabel.getPreferredSize().width + fm.stringWidth(textLabel.getText()) + i.left + i.right;
    int cwidth = table.getColumnModel().getColumn(column).getWidth();
    dim.width = swidth > cwidth ? cwidth : swidth;

    if (isSelected) {
      textLabel.setOpaque(true);
      textLabel.setForeground(table.getSelectionForeground());
      textLabel.setBackground(table.getSelectionBackground());
      iconLabel.setIcon(sicon);
    } else {
      textLabel.setOpaque(false);
      textLabel.setForeground(table.getForeground());
      textLabel.setBackground(table.getBackground());
      iconLabel.setIcon(nicon);
    }
    return panel;
  }
示例#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;
 }
示例#3
0
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   if (isSelected) {
     setForeground(table.getSelectionForeground());
     setBackground(table.getSelectionBackground());
   } else {
     setForeground(table.getForeground());
     setBackground(table.getBackground());
   }
   setFont(table.getFont());
   setText(Objects.toString(value, ""));
   return this;
 }
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   if (isSelected) {
     button.setForeground(table.getSelectionForeground());
     button.setBackground(table.getSelectionBackground());
   } else {
     button.setForeground(table.getForeground());
     button.setBackground(table.getBackground());
     laLigneSelectionnee = row;
   }
   label = (value == null) ? "" : value.toString();
   button.setText(label);
   isPushed = true;
   return button;
 }
示例#5
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;
  }