Link to home
Start Free TrialLog in
Avatar of Zolf
ZolfFlag for United Arab Emirates

asked on

resize image


hello there,

I get my image into a Jframe from the database which workes fine.but now my problem is the images are of different sizes.how can i adjust the JFrame according the image.

public static void main(String[]args)
      {
            Frame frame = new DBImage();            
            Toolkit toolkit = Toolkit.getDefaultToolkit();
            Dimension scrnsize = toolkit.getScreenSize();
            //frame.setSize( (int) scrnsize.getWidth(),(int)scrnsize.getHeight());
            frame.setSize(700,100);
            frame.show();
      }

cheers
zolf
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Change

frame.show();

to

frame.pack();
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try

Dimension size = frame.getSize();
int width = size.width;
int height = size.height;
frame.setSize(new Dimension(width, height));
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> frame.setSize(new Dimension(width, height));

and this should be different, set to the frame you want, otherwise you will resize the same frame :) Didn'ty wake up completely yet :)
SOrry! My first answer has a silly error. Of course i meant

 Change

frame.setSize(......................................);

to

frame.pack();
:-)