Solved

resize image

Posted on 2006-07-03
7
191 Views
Last Modified: 2010-03-31

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
Comment
Question by:zolf
  • 4
  • 3
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 17029405
Change

frame.show();

to

frame.pack();
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 105 total points
ID: 17029406
(and you can get rid of any manual sizing)
0
 
LVL 35

Expert Comment

by:girionis
ID: 17029410
Try

Dimension size = frame.getSize();
int width = size.width;
int height = size.height;
frame.setSize(new Dimension(width, height));
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Assisted Solution

by:girionis
girionis earned 20 total points
ID: 17029415
> int width = size.width;
> int height = size.height;

should be getWidth() and getHeight()
0
 
LVL 35

Expert Comment

by:girionis
ID: 17029418
> 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
 
LVL 86

Expert Comment

by:CEHJ
ID: 17029421
SOrry! My first answer has a silly error. Of course i meant

 Change

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

to

frame.pack();
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17029431
:-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 236
Way to decrease size of apk file 9 104
Cisco ASA: Java web start no go, asdm launcher no go 3 56
import as existing maven project 3 34
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question