Forums Register Login

I got a problem about JFrame.

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
hello,

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

Conan
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1169 times.
Similar Threads
Fixing size of components in JFrame
Opening a JFrame maximized
Layout manager and resizing
Problem with JTree inside JScrollPane inside JPanel
How to size jsplitpane?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:34:37.