Forums Register Login

Graphic with a JPanel

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
I need a new interior decorator. This tiny ad just painted every room in my house purple.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 862 times.
Similar Threads
Overflow
Increasing the size of the Panel
Scrollable JPanel Drawing in JScrollPane
JScrollPane and paint
Swing bug? scrolling in BLIT_SCROLL_MODE with painting JTextArea components hangs app
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 05:08:50.