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 JFrame resize problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
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: 38818
    
  23
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: 38818
    
  23
You're welcome. That video is a great favourite with GUI designers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFrame resize problem