Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JScrollPane is being a real JScrollPAIN....!!!!!!!!!

Status
Not open for further replies.

JProg

Programmer
Apr 4, 2002
88
JP
Hi Everyone,

I am adding components to a Box container, and making that container the client of a JScrollPane. From their I am adding the JScrollPane to the contentPane of a JFrame. All is well in regard to adding the components and then dispalying everything. However the vertical srollBar belonging to the JScrollPane is not starting from the top of the content that I am displaying. Instead the scrollBar is starting right at the bottom of the displayed content.

Roughly the code that I have created (in a very abbreviated form) looks like this:
Code:
Box box = new Box();
JScrollPane scroll = new JScrollPane(box);
getContentPane.add(scroll);
I have tried a number of methods in an attempt to start the content from the top, e.g.: srollRectToVisible(new Rectangle(...)), however my efforts so far have arrived at naught. The layout manager for this arrangement is the default for the box container, BoxLayout.

If anybody knows of any ways to make the scrollBars in a JScrollPane behave themselves, insights will be greatly appreciated.... I am beginning to understand the motive behind calling this a JScrollPAIN!!!

Thanks in advance for your kind assistance.

Davo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top