posted 12 years ago
Hi, thank you for your help so far.
There is another question I would like to ask in this context: Basically I have a JPanel inside a JScrollPane with is inside a JInternalFrame now. By following your advice of adding the "getPreferredSize()" method to the JPanel class I managed to make the scrollPane bars visible. However, in the meanwhile I added a zooming function which basically draws my loaded image according to a certain scale factor on the JPanel. The image can be resized by mouse events. This works fine, however the dimension of the bars of the JScrollPane do not adjust accordingly. They adjust if I resize the JInternalFrame. But not directly after my mouse action to resize the image.
How can I make the bars adjust directly after my repaint?
Edit: I already tried to call scrollPane.revalidate(); but it only seems to help partially: At the beginning only the vertical scrollbar is visible, since the image is smaller than the viewport in horizontal direction. When I zoom the image, nothing happens as long as the image width is smaller than the width of the viewport. As soon as the image width gets larger than the viewport width, the horizontal scrollbar appears and the vertical also gets updated to is supposed "size". If I continue zooming after that, both scrollbars do not change any more. (Only if I adjust the frame size, the scrollbars do also update according to the size of the JPanel on which my resized image is drawn).
Thank you & regards,
Marc