Solved

resize image

Posted on 2006-07-03
7
189 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from 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.

Question has a verified solution.

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

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

816 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now