• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

JTable auto select row

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22256
119
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about JTable's setRowSelectionInterval method?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic