I have a main JPanel which implements Scrollable and uses a BorderLayout. It contains one NORTH readonly JEditorPane, one CENTER JPanel with a FlowLayout whereby JButtons are a
The problem is that the FlowLayout does not recalculate the preferred size when buttons are wrapped to the next row.
You should be able to use the WrapLayout.
WrapLayout extends FlowLayout and sets the proper preferred size when components wrap to a new row.
WrapLayout
FlowLayout