File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes I got a problem about JFrame. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "I got a problem about JFrame." Watch "I got a problem about JFrame." New topic
Author

I got a problem about JFrame.

Yanxin Zhao
Ranch Hand

Joined: May 05, 2004
Posts: 65
Hi, everybody,
I wanted to implemented that a JButton in a JFrame, And when I click which button, a picture will be displayed on the JFrame. But how can I enable the size of the JFrame be changed into a suitable size ? And this is also my problem.
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
You use setSize(width, height) to change the size of a JFrame. How are you getting/storing the image? The Image class has getHeight() and getWidth() methods.
Kai Witte
Ranch Hand

Joined: Jul 17, 2004
Posts: 356
hello,

when the Component that displays your image automatically has the correct preferred size, you can use JFrame#pack().

Conan


Kai Witte's business website Kai Witte's private homepage
Yanxin Zhao
Ranch Hand

Joined: May 05, 2004
Posts: 65
Thanks so much for your replyes. But I do not think that setSize() and pack() can do what I wanted to do. I used this to show my pic.


Although the pic can be add into JFrame, but the size of JFrame still can not be changed.
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
Hmm, I tried changing your code and making it change the size of the parent component as well, but that didn't work either. Now I'm kind of stuck too
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I got a problem about JFrame.