Resizing canvas in scrollpane
I'm trying to load a different image into a scrollpane whenever the user clicks a button.
The images have different sizes.
How do I get my canvas to resize to the actual size of the image ?
The scrollbars on the scrollpane remains the same, so the larger image gets cropped to the size of the smaller image.
Thanks in advance for responding to this post.
Re: Resizing canvas in scrollpane
I have a similar problem, i've tried to invalide and then validate the ScrollPane but it doesn't work.
If someone knows the answer it would be of GREAT help !!
Re: Resizing canvas in scrollpane
I also have the same problem, to me it seems like the first image you load in to the scrollpane sets the size of it. So I have a very big Panel whit some text in it(where I explain how to use this program) as a first image, and after that I can load the smaler canvas.
Re: Resizing canvas in scrollpane
ummm...have you tried getting the size of the actual image using
int width = image.getWidth(this);
int height = image.getHeight(this);
then using the handle of the canvas together with the command "resize". If you then call "validate" this should resize your canvas!
Casa