is JTextPane an acceptable client of JScrollPane?
I have JTextArea working with scroll bars provided by JScrollPane. Following that pattern I have not been able to get JTextPane to show up with scroll bars.
Essentially I attach text to the JScrollPane as follows:
myJScrollPane.setViewportView(myJTextArea); // does not work with myJTextPane,
开发者_如何转开发 // an instance of JTextPane
No exception is thrown, the scroll bars, both horizontal and vertical simply do not appear.
Try
JScrollPane myJScrollPane = new JScrollPane(myJTextArea);
myJScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
Check whether setPreferredSize() was not called and preferred size isn't set for the JTextPane.
精彩评论