Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Graphic with a JPanel" Watch "Graphic with a JPanel" New topic

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?
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).
I agree. Here's the link:
subject: Graphic with a JPanel
It's not a secret anymore!