• Post Reply Bookmark Topic Watch Topic
  • New Topic

How To Highlight Slected Row In A JTable  RSS feed

 
Fran Varin
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTable that I initialize with one blank row by using the table model's constructor. I then select the row programatically just after I instantiate the JTable using "jTable.setRowSelectionInterval(0,0)". When the table renders I have my headings and the one blank row but, the line is not highlighted in any way. If I click on the row I receive the highlighting.

The behavior I'm trying to achieve is to have the row highlighted when I set the selected row programatically. There may be times (ex. on a right mouse click) when I would like this behavior as well. But, for now if I can get the scenario above to work I'll consider that a huge step forward.

Thanks for all replies.
Fran
 
Nick Meverden
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
checkout JTable.changeSelection()
[ July 12, 2006: Message edited by: Nick Meverden ]
 
shansi raj
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try using table.getSelectionModel().setSelectionInterval(index1,index2);
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!