Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Kenneth Bennett   on Aug 08 In Java Category.

  
Question Answered By: Anita Karacs   on Aug 08

Hi Kenneth,

I had the same issue, and I spent a lot of time by searching for answer, when I found your post. This led me to solve this problem, and you almost solved it too. The last step should be creating a custom celleditor (extends DefaultCellEditor), and overriding the getTableCellEditorComponent() method, put these into the first two line:

table.setColumnSelectionAllowed(false);
table.setRowSelectionAllowed(true);

The full method:
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
table.setColumnSelectionAllowed(false);
table.setRowSelectionAllowed(true);
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
}

So when you click inside a cell, not the header, the cell editor will set the selection as desired.
I hope you will manage to solve your problem like I did. :)

Best,
Anita

Share: 

 
 
Didn't find what you were looking for? Find more on Selecting a JTable Column Or get search suggestion and latest updates.


Tagged: