views:

15

answers:

0

I'm doing a homework assignment where I need to display an image and then allow the user to resize the image witha JSlider. I have the image displaying, but Im not sure how I could use a slider to change the size. As I understand sliders, there are 3 parameters that control the default value, the max slider value, and the min slider value.

Could I reference these numbers in some kind of equation that determines what dimensions to set the image at??

Also, I need scrollbars if the image is bigger than the frame. currently my scrollbars will show up but the image will still stretch the frame to just below the size of the image. is there somewhere i can set the dimension limits for the scrolling? this is what I'm trying unsuccessfully at the moment:

JScrollPane scrollPane = new JScrollPane(image);
        scrollPane.setPreferredSize(new Dimension(500,500));
        scrollPane.setBounds(frame.getWidth()-image.getWidth(), 0, frame.getHeight()-image.getHeight(), frame.getHeight());
        frame.add(scrollPane);