开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜