Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

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
0
zolf
Asked:
zolf
  • 4
  • 3
2 Solutions
 
CEHJCommented:
Change

frame.show();

to

frame.pack();
0
 
CEHJCommented:
(and you can get rid of any manual sizing)
0
 
girionisCommented:
Try

Dimension size = frame.getSize();
int width = size.width;
int height = size.height;
frame.setSize(new Dimension(width, height));
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
girionisCommented:
> int width = size.width;
> int height = size.height;

should be getWidth() and getHeight()
0
 
girionisCommented:
> 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 :)
0
 
CEHJCommented:
SOrry! My first answer has a silly error. Of course i meant

 Change

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

to

frame.pack();
0
 
CEHJCommented:
:-)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now