use*_*003 5 java swing jtextpane word-wrap
我的程序有问题..WordWrap 能够...
确切地说,我想使用 linwrap 但我不想使用 wordwrap...
我搜索了这个
JTextPane textPane = new JTextPane();
JPanel noWrapPanel = new JPanel( new BorderLayout() );
noWrapPanel.add( textPane );
JScrollPane scrollPane = new JScrollPane( noWrapPanel );
Run Code Online (Sandbox Code Playgroud)
当我使用此代码时,换行和自动换行都被禁用......
我想使用换行......
对不起,我糟糕的英语能力......我相信你能明白我的意思,请帮助我......
这里是 :
// 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;
}
Run Code Online (Sandbox Code Playgroud)