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() );
Array ( ) 2 Responses to “Stop JTextField from expanding in BoxLayout”
Leave a Reply
You must be logged in to post a comment.
January 1st, 2013 at 6:40 pm
Thanks a lot.
September 4th, 2014 at 10:57 pm
Thanks 🙂