• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to disable JTable cell/row selection?

 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Reader,
I have a JTable and when I click on a row one cell is selected (high lights).
Question: How to disable cell/row selection when it is clicked by mouse?
Did the following but it did not work

Thank you in advance
Garandi
[ August 20, 2003: Message edited by: Garandi Garandi ]
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not getting what your problem is.
Do you have to show that no cell is selected when mouse clicked or to disable cells in the Table?
 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijay,
Yes, I want to show no cell is selected when it is clicked my mouse.
Thank you
Garandi
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then use your TableCellRenderer component, with its Background color is table's Background and Foreground color to table's Foreground.
class CustomRenderer extends JLabel implements TableCellRenderer
{
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
{
setBackground(table.getBackground());
setForeground(table.getForeground());

return this;
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic