• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JFrame resize problem

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome. That video is a great favourite with GUI designers.
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic