• 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

How to implement AutoScroll?

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