Selecting a Jtable - Java

2

When I select a row, everything is selected but the cell that I select at the edge appears a few dots, as I could remove them or modify them. The property of the JTable that I use to select the whole row is: rowSelectionAllowed

    
asked by Leandro 02.03.2017 в 22:10
source

1 answer

0

You must make a specific render that does not put an edge in the selected cell:

//En tu caso es la columna nº 1
getColumnModel().getColumn(1).setCellRenderer(new TableCellRenderer() {

  @Override
  public Component getTableCellRendererComponent(JTable table, Object value,
     boolean isSelected, boolean hasFocus, int row, int column) {
     Component c = table.getDefaultRenderer(table.getColumnClass(column))
        .getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

     //Si la celda está seleccionada quitamos el borde
     if(isSelected)
        ((JComponent)c).setBorder(null);

     return c;
  }
});
    
answered by 03.03.2017 / 08:42
source