Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes Graphic with a JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Graphic with a JPanel" Watch "Graphic with a JPanel" New topic
Author

Graphic with a JPanel

cardwell cupp
Ranch Hand

Joined: Aug 16, 2001
Posts: 66
I am writing a little program that draws circles inside a JPanel. I put the Jpanel inside a JScrollPane, but when the circles are bigger than the area, it wont scroll. Why is this happening?
thanks
cardwell
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Cardwell,
The JScrollPane asks the JPanel what size it would prefer to be and uses that size. Your circles are not objects that need to be managed therefore the JPanel layout doesn't use them to give its' preferred size. You need to set the JPanel preferred size so that the JScrollPane knows that it is not the same size as its child (JPanel).
Regards,
Manfred.
 
 
subject: Graphic with a JPanel
 
Similar Threads
Canvas appears in JFrame but not JPanel
Different Colour for different group of overlapping circles.
How to draw circles whose center coordinates are stored in an array?
Simple JPanel question
Drawing circles using the coordinate values that are stored in an ArrayList.