This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JFrame resize problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame resize problem" Watch "JFrame resize problem" New topic
Author

JFrame resize problem

Hesham Gneady
Ranch Hand

Joined: Feb 26, 2007
Posts: 66
Hi Ranchers ,

When the user resizes the JFrame in my program, i want to determine the new location for some components in that JFrame to fit the new size.

Well, it works fine the first time the user resized the JFrame, it works correctly. However, the second time they resized the JFrame, seems like all the components get back to the original coordinates again (before my 1st resize) so my 2nd resize becomes inaccurate.

Here's a sample of the code :


Am i doing something wrong here ?
[ August 27, 2008: Message edited by: Bear Bibeault ]

Hesham
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38025
    
  22
Why aren't you using a LayoutManager?

There are all sorts available, which you can find out from the Java Tutorials. If you want to use GridBag, there is a very useful utility class here, and a slightly less useful utility here .
Hesham Gneady
Ranch Hand

Joined: Feb 26, 2007
Posts: 66
ha ha ... Nice video

Actually i was already using a layout, i just didn't know how to force it to resize the components automatically when resizing or maximizing the window.
Now i've got it ... Thanks a lot.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38025
    
  22
You're welcome. That video is a great favourite with GUI designers.
 
Don't get me started about those stupid light bulbs.
 
subject: JFrame resize problem
 
Similar Threads
rectangles
Adjusting the size of an image (jpg)?
[new user!] I've got an undecorated window, how can I make it resizable?
Resize an image while maintaing its aspect ratio..
Resizing JPG using Graphics2D