| 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: 354
|
|
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 Mock exam / preparation kit reviews
|
 |
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
|
 |
 |
|
|
subject: I got a problem about JFrame.
|
|
|