May 19

When you add a JTextField to a BoxLayout managed panel it will expand vertically to take up available space.

To avoid this you can simply set the maximum size of the field to be the same as its preferred size.

textField.setMaximumSize( textField.getPreferredSize() );

written by objects \\ tags: , ,