tags:

views:

38

answers:

2

Apparently if the columns size is more than 70 the field get's displayed with a size where you cannot even type a single character? I'm talking about:

new JTextField(70);
A: 

My guess is that you are using a GridBagLayout. If there is not enough space to display the component at its preferred size the component shrinks to its minimum size which I believe is 0. Try giving your component a minimum size or use a different layout manager.

If you need more help post your SSCCE.

camickr
A: 

Passing in the number of columns adjusts the text field's preferred size. As camickr points out, you may be using a layout that under certain circumstances will use the minimum size which is zero.

If you wish to force the minimum size to be the preferred size (and that may or may not be a good idea), you can do:

textField.setMinimumSize(textField.getPreferredSize());
Avrom
this works, except for that it squeezes the other components. Need to tell it to resize the components somehow (fontwise).
simpatico