Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Forcing a cell selection in a JTable

 
Aaron Roberts
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to select a cell in a JTable programmtically. I have the SelectionModel for the rows and columns. When I use the following -

I don't see the selection occuring. I know it is though, as I have a class which implements ListSelectionListener and TableColumnModelListener to notify me of cell selections. This class updates values on the screen, based on the current selection in the table.
In essence, if I click in the table, I see the cell highlight and the screen changes, based on my selection. When I do the selection programmtically, the cell does not highlight, but the screen does update to reflect what should be selected.
Any thoughts?
Regards,
Aaron R>
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me a single column is selected..
table.setColumnSelectionAllowed(true);
table.getSelectionModel().setSelectionInterval(row, row);
table.getColumnModel().getSelectionModel().setSelectionInterval(col, col);
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!