//final JScrollPane scrollSpecific = new JScrollPane(forSpecific,
// ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
// ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
final JScrollPane scrollSpecific = new JScrollPane(forSpecific);
Not the problem but the "scrollbar as needed" is the default. You don't need to specify this.
Inside of the ScrollPane is a panel with BoxLayout and X_Axis - align. (it contains arbitrary number of Panels with fixed (prefference)Size.
What is a fixed size?
- the "main" panel added to the scrollpane
- the "child" panels added to the main panel
In any case the size should not be fixed, the layout manager should determine the preferred size. Or if you are creating a custom component then you should override the getPreferredSize()
method to return the proper size so the layout manager can do its job.