Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to implement AutoScroll?  RSS feed

 
Yaroslav Chinskiy
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a table that is updated dunamically.
The new data is inserted to the top of the table.

I want to force the scroll to show the new data. So if the data is out of the visible rect. i want the scroll to show it.

I extended JScrollPane but it does not work:



Any ideas?
Thank you.
 
Joe Ess
Bartender
Posts: 9425
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the documentation for JScrollPane, you'll see that it inherits the method scrollRectToVisible from JComponent, which documents the method as:

Forwards the scrollRectToVisible() message to the JComponent's parent. Components that can service the request, such as JViewport, override this method and perform the scrolling.

So you are attempting to tell the component that JScrollPane resides on to scroll What you want to do is tell the JTable's parent (i.e. JScrollPane) to scroll to a particular visible rectangle (and one that isn't one pixel high and one pixel wide):
 
Yaroslav Chinskiy
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe,

Thanks for help. It works now.

However, I have to debug a code written by someone else, and the method has no effect in his class.

What may stop scroll method from getting to the JScrollPane?
[ August 03, 2004: Message edited by: Yaroslav Chinskiy ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!