Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

JTable positioning row at top  RSS feed

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I'm trying to develop a JTable so that I can position a specific row at the TOP of the JTable.
I've seen examples using scrollRectToVisible() but this just makes the row visible but if the row is below the viewport it puts the row at the bottom not the top.
If the row is above the viewport then it works ok.
I've got it to work by issuing the scrollRectToVisible() method twice. Once with a v large row number then the actual one to force the row above the viewport on the first call. This seems very clunky/inefficient though!
Does anyone have any ideas.
As an extension to this I also want to position a row to the top even if the view is large enough to display all the rows, hence no scrollbar.
TIA Graham
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Graham,
Why not do it with the table model? Whatever row it is you want displayed at the top, could be returned in the getValueAt method of the table model. You would of course have to keep up with that row in the model.
Hope this helps,
Michael Morris
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!