This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Dialog resize problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Dialog resize problem" Watch "Dialog resize problem" New topic

Dialog resize problem

Frans Janssen
Ranch Hand

Joined: Dec 29, 2004
Posts: 357
Hi all,

A question for the Swing experts here: I have a JFrame for my server task that uses GridBagLayout. It contains two JTextFields:

When I reduce the size of the frame (by resizing it with the mouse), the lower text field immediately drops to a very small size (this happens already if a reduce the size with only a few pixels):

I fiddled around with the GridBagConstraints, but have yet failed to find the settings that solve the problem. Anyone knows how to do this?

I don't mind that the text field becomes smaller when the frame gets smaller; I just don't want it to jump to zero-size.

Many thanks,


P.S. this is the code used to build the frame:
[ January 10, 2005: Message edited by: Frans Janssen ]

Steve Smith

Joined: Jul 03, 2005
Posts: 26
I realise that this is an old post, but thought I would reply anyway. Perhaps it will help someone if not the original poster. What is happening is that the JTextField is shrinking to its minimum size. My solution to this is to use setMinimumSize() and setPreferredSize() on the JTextField, using the same value for both calls and specifying the size that you want the field to be in both calls. This has solved the problem for me.
subject: Dialog resize problem