• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

jtable and the scrollbar

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Has anyone ever programitcally changed their horizontal scrollbar?

I'm using a JTable in a scrollPane and I need to take three simple steps:

1. get the current position of the horizontal scroll bar
2. recreate the table with new data (not a problem)
3. reposition the scrollbar on the new table to the same position as the old table

Can anyone give me an idea how to get the horizontal scrollbar position?

I tried this approach but haven't had much luck:

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeff,

Have you tried using the ScrollPane method

setScrollPosition( int x, int y )

You can use it with the Point instance that you've already created in your example code:

setScrollPosition( Point p )

If I had the time I would try this out myself and give you a definitive answer. Try dropping the references to viewPort as well.

Might also be worth getting the scroll position BEFORE you remove the object whose scroll position you're interested in, just a thought.

So try this:



Hope there's something useful to you there.

Andy.
 
reply
    Bookmark Topic Watch Topic
  • New Topic