Hi there
I am using a JScrollPane to show a picture that I can zoom into and zoom out of using separate buttons.
When I zoom out of the image and make the image smaller than the Viewport, the image goes smaller for a second and then resizes to fit exactly into the Viewport.
I see in the API that
By default JScrollPane uses ScrollPaneLayout to handle the layout of its child Components. ScrollPaneLayout determines the size to make the viewport view in one of two ways:
If the view implements Scrollable a combination of getPreferredScrollableViewportSize, getScrollableTracksViewportWidth and getScrollableTracksViewportHeightis used, otherwise
getPreferredSize is used.
I had to make my own component to put the image on, and that has a getPreferredSize() method. And I don't know how to make the view implement Scrollable.
Does anyone have any suggestions to help fix this?
Cheers,
Rachel
(When the image is larger than the scroll pane, the behaviour is as expected and the scrollbars appear so that I can move to see the hidden parts of the image.)