In an application, I\'m using uneditable JEditorPanes as a sort of a generic UI widget that can display somewhat complex content (HTML will do the trick), wrap text lines an
The scrollbars of a JScrollPane appear if the size of the viewport become smaller than the preferred size of its view component. Set the preferred size of the panel in the scroll pane, or set the preferred size of each of the editor panes : the preferred size of the panel will be the composition of the preferred sizes of the editor panes (sum of the preferred height, and max of the preferred widths)
// JPanel panel = new JPanel();
ScrollablePanel panel = new ScrollablePanel();
panel.setScrollableWidth( ScrollablePanel.ScrollableSizeHint.FIT );
See Scrollable Panel for the class and an explanation on how the class works.