adicionei o seguinte comando para pintar algumas linhas da tabela:
public void addCor() {
// minha table se chama jTable1, se precisar troque o nome
Cadastro_Produto.produtos.setDefaultRenderer(Object.class, new javax.swing.table.DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(Cadastro_Produto.produtos, value, isSelected, hasFocus, row, column);
if (Float.valueOf(table.getValueAt(row, 7).toString()) > 0) {
setBackground(new Color(255, 204, 204));
} else {
setBackground(null);
}
return this;
}
});
até aí tudo certo, mas agora quando tento selecionar uma linha da tabela, ela seleciona a celula, e não mais a linha toda...
tentei usar o comando:
Cadastro_Produto.produtos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
mas não resolveu, alguém sabe me ajudar?
OBS: não me crucifiquem, estou usando DefaultTableModel, pois começei o projeto antes de conhecer o GUJ e a merda da Jtable ;/