File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jtable and the scrollbar

 
jefff willis
Ranch Hand
Posts: 113
  • 0
  • Mark post as helpful
  • send pies
  • 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:

 
Andy Nimmo
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic