• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Dialog resize problem

 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,

Frans

P.S. this is the code used to build the frame:
[ January 10, 2005: Message edited by: Frans Janssen ]
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Have you no shame? Have you no decency? Have you no tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic