开发者

is JTextPane an acceptable client of JScrollPane?

开发者 https://www.devze.com 2023-04-06 00:03 出处:网络
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.

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

精彩评论

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

关注公众号