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.
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
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...
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
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.
subject: How to disable the [ - ] resizing of a frame