我的程序有问题..它是 WordWrap 能够...
确切地说,我想使用 linwrap 但我不想使用 wordwrap...
我搜索过这个
JTextPane textPane = new JTextPane();
JPanel noWrapPanel = new JPanel( new BorderLayout() );
noWrapPanel.add( textPane );
JScrollPane scrollPane = new JScrollPane( noWrapPanel );
当我使用这段代码时,linewrap 和 wordwrap 都被禁用....
我想使用换行....
对不起我糟糕的英语水平... 我相信你能明白我的意思 请帮助我...
最佳答案
在这里:
// Override getScrollableTracksViewportWidth
// to preserve the full width of the text
public boolean getScrollableTracksViewportWidth() {
Component parent = getParent();
ComponentUI ui = getUI();
return parent != null ? (ui.getPreferredSize(this).width <= parent
.getSize().width) : true;
}
关于java - 如何在 Java JTextPane 中禁用 WordWrap?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23149512/