This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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));
use the getVerticalScrollBar() and getHorizontalScrollBar() methods of JScrollPane, and then call setValue on them. example:
use the [CODE] tags - it makes it much easier for people to help you.
Joined: May 07, 2003
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
Joined: Apr 24, 2002
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.