aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to disable the [ - ] resizing of a frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to disable the [ - ] resizing of a frame" Watch "How to disable the [ - ] resizing of a frame" New topic
Author

How to disable the [ - ] resizing of a frame

bobby, morkos
Ranch Hand

Joined: Jan 04, 2002
Posts: 82
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.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

If it's a JFrame you can't disable that.


GenRocket - Experts at Building Test Data
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
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


Rob
SCJP 1.4
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

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


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to disable the [ - ] resizing of a frame