I'm writing a desktop application. The environment is following:
- Java SE 10
- Eclipse IDE
- Java Swing
- MigLayout
The source-code, the important parts.
textPane = new JTextPane();
textPane.setDoubleBuffered(true);
textPane.setLayout(new MigLayout("debug", "[grow]"));
textPane.setContentType("text/plain");
textPane.setBorder(new LineBorder(new Color(0, 255, 0), 1, true));
scrollPaneScratches = new JScrollPane(textPane);
scrollPaneScratches.setAutoscrolls(true);
That's the JTextPane area where I add, at run-time, some components.
This is where I add the components in:
for(int key : keys) {
JLabel header = retrieveHeader(key, types, allScratches);
textPane.add(header, "wrap, growy");
JTextPane txt = new JTextPane();
txt.setText(allScratches.get(key).getScratches());
textPane.add(txt, "wrap, growy");
}
Now what the problem is, that the JTextPane, which displays the components added at run-time, is not scrollable. That's, the vertical scroll-bar supposed to appear, though but it does not.
Here is the image:
I tried different layout managers, but the contents is still not scrollable.
Why do not I get the scroll-bars? N.B., I did use the search engine on this, for about a day.
Best regards

Well, I resolved my issue by following the suggestions by @camickr, provided under the comments section.
That's, the new components I add under JPanel, rather than on JTextPane. In that case, the scroll-bars do appear as expected.
That is: