• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTable positioning row at top

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic