• 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 get JScrollPane to go to top left??

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a series of JPanels that are embeded in a single JPanel that resides in a JScrollPane.
Each time I call show() on the JInternalFrame within which this all resides it ends up displaying the top in a flash and then scrolls to the bottom. I need the display to remain at the top of the JScrollPane.
I have tried several things both before and after calling JInternalFrame show() all to no avail.
Any ideas would be greatly appreciated.
Example of tried code:
mainScrollPane.scrollRectToVisible(new Rectangle(0,0,20,50));
 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use the getVerticalScrollBar() and getHorizontalScrollBar() methods of JScrollPane, and then call setValue on them.
example:
 
Lee Barney
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I added your code in and put a print statement prior to and after the call to show. Both indicate that the position of the vertical scroll is zero and yet the scroll bar is at the bottom of the panel.
Very confusing to me. I have gone back again to make sure that I am using the correct panel and have verified that I am.
Any ideas?
Thanks
 
Jon Dornback
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have used that method in a couple apps, and seems to work fine for me. if you have some sample code, i'll take a look at it if you post it here.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic