BoxLayout expands components to the maximum size, JTextField erroneously returns the maximum height of Short.Max (or Integer.Max, forgot). The way out is to make the field behave:
@Override public Dimension getMaximumSize() {
Alternatively use a different LayoutManager :-)
source share