如何使JTextPane水平滚动 [英] How to make JTextPane scroll horizontally
本文介绍了如何使JTextPane水平滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个JTextPane
,当行太多时,会出现一个vertical
滚动条,但是当一行太长时,它会分成两行,而不是出现水平滚动条,该怎么办?使水平条出现而不是分成两行,我的jTextPane
像这样添加:
I have a JTextPane
, when there are too many lines, a vertical
scroll bar appears, but when a line is too long, instead of appearing a horizontal scroll bar, the line breaks into two lines, how to make the horizontal bar appear instead of breaking into two lines, my jTextPane
is added like this:
JScrollPane jScrollPane1 = new JScrollPane();
jScrollPane1.setViewportView(jTextPane1);
推荐答案
如由我们自己的Rob Camick ="=" nofollow>这里,您可以尝试使用类似...
As presented here by our very own Rob Camick, you could try using something like...
JTextPane tp = new JTextPane() {
@Override
public boolean getScrollableTracksViewportWidth() {
return getUI().getPreferredSize(this).width
<= getParent().getSize().width;
}
};
哪个会停止换行/换行
这篇关于如何使JTextPane水平滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文