aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to disable JTable cell/row selection? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to disable JTable cell/row selection?" Watch "How to disable JTable cell/row selection?" New topic
Author

How to disable JTable cell/row selection?

Garandi Garandi
Ranch Hand

Joined: Jan 07, 2003
Posts: 192
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

Joined: Aug 04, 2003
Posts: 175
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

Joined: Jan 07, 2003
Posts: 192
Vijay,
Yes, I want to show no cell is selected when it is clicked my mouse.
Thank you
Garandi
VIJAY Yadlapati
Ranch Hand

Joined: Aug 04, 2003
Posts: 175
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;
}
}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to disable JTable cell/row selection?