• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JFrame resize problem

 
Hesham Gneady
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Campbell Ritchie
Sheriff
Pie
Posts: 49796
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49796
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome. That video is a great favourite with GUI designers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic