Forums Register Login

repaint in ScrollPane does not work correctly

+Pie Number of slices to send: Send
I have a scollpane and a Panel in it.
Without the scollpane, I can resize my Panel as I want, it repaints always correctly.

I don't use any Layout manager, I ask how much size does my frame gives me to draw and then calculate all relative corrdinates from this numbers.

Why does it display wrong when scrolling in the scrollpane?
Is it possible to catch all the events, that my scollpane sends to my Panel?

Maybe that would be a way to see what really happens/what goes wrong...
+Pie Number of slices to send: Send
Each time the JScrollPane must validate itself it looks for the size of its viewports child, your JPanel, which it uses to set its scrollbars. So your custom component must let the JScollPane know what size it is or wants to be shown with. One way to do this is to override the JComponent method getPreferredSize in your component and return the desired Dimension. The JScrollPane will ask for this during each validate episode.

Calling the JComponent method revalidate on an instance of MyPanel in your event code signals the JScrollPane to validate itself.
What's that smell? I think this tiny ad may have stepped in something.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1124 times.
Similar Threads
Manually sizing JScrollPane
add a JTextPane to a JScrollPane
JTable - JDBC - Vectors
how can i refresh a scrollpane
ScrollPane problem
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:03:47.