• 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

How to disable the [ - ] resizing of a frame

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have coded an application using frames and whenever, I resized the frame GUI changes and it looks weird. I just need to disable the re-sizing to solce this problem. Does anyone know how to do this in Swing? Thanks in advance.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it's a JFrame you can't disable that.
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sadly, yes this is true, you can't constrain a JFrame's size like that.
The JFrame is a heavy-weight peer component; when you put up a JFrame, the VM is actually putting up an OS native window frame, but provides no API for you to restrict the window size, or change the look of the native window, etc.
You can, however, use JInternalFrames, of which you have complete control since they're lightweight, and restrict their size. Changing your JFrames to JInternalFrames is not that hard, since the JInternalFrames were written to "act" just like JFrames and have most of the same API methods.
Rob
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys, what about setResizable( false )?
This disables resizing the frame by dragging on it's borders or clicking on its title bar, and it disables the maximize button on the frame.

The previous posts are correct if you are trying to disable the minimize button on the JFrame ( you can kinda disable this by making it listen for the event and then restore the frame ), but minimizing doesn't resize the frame anyway, so this shouldn't be a problem...

-Nate
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I generally do not think locking the size is a good idea. Unless it is a small dialog. You are making the assumption that all users use the same size monitor and have the resolution set the same. Learning the layout managers goes along way in making the GUI presentable with all resolutions and resizing. The next step that many take is to use the null layout. Do yourselves a favor and learn to use the layout managers.
 
We can fix it! We just need some baling wire, some WD-40, a bit of duct tape and 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