JScrollPane Problem
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Dimitris_Pierrakos
Posted On:   Monday, March 26, 2001 10:14 PM

I draw something using a JPanel. Then I put the JPanel into a JScrollPane.
The problem is that none of the ScrollBars appears.

Re: JScrollPane Problem

Posted By:   Christopher_Schultz  
Posted On:   Tuesday, April 3, 2001 07:42 AM

When you stick something into a JScrollPane, scrollbars only appear by default if the contained widget is bigger than the JScrollPane. So, if you have a 100x100 JScrollPane and a 50x50 JPanel inside of it, you get no scrollbars.



You will probably have to explicitly set the size of the JPanel before you place it inside of the JScrollPane.



If you want to force the scrollbars to be visible no matter what, you can call JScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS) and the similar method for the vertical scrollbar. You can also specify those attributes of the JScrollPane in one of the constructors.



-chris
About | Sitemap | Contact