Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable auto select row  RSS feed

 
Johan den Boer
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a JTable in a JScrollPane with for example 1000 rows. In my program I want random select a row and highlight this selected row. I search the internet but can not find how to to do it. Another question is : how can i select this row set this selected row in the middle of the scrollpane

thanks a lot

Johan
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about JTable's setRowSelectionInterval method?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> In my program I want random select a row and highlight this selected row..

table.changeSelection(...);//using random row number


> how can i select this row set this selected row in the middle of the scrollpane

table.scrollRectToVisible(table.getCellRect(..));
but this won't put it in the middle - will need further adjustment
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!