This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
controlling size of a JFrame
Posted by Mohapatra on September 23, 2001 at 2:52 AM
I want a Jframe to be of constant height(let's say 300). User should be able to change the width of the JFrame, but the height of the JFrame cannot be changed. I tried to catch the componentResized event and then change the height to original height. But there are some problems, 1) when user resizes by dragging the broder of the frame, no event comes, After resizing, the resized event comes. So in componentResized event if I do setSize(the current widht, 300)) there is a flickering. 2) In case of maximize, though it is OK, but restoring the size will not happen. Because after maximize, if I do setSize(), while restoring the size by again clicking on maximize button, it will find that the frame is not in maximized state so again maximize it. So the size cannot be restored.
It should work like windows Search File(start->search->folder/file).
Thanks in advance.