JTextPane换行 [英] JTextPane line wrapping

查看:84
本文介绍了JTextPane换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JTextArea 不同, JTextPane 没有选项可以关闭换行。我找到一个解决方案来关闭 JTextPane中的换行 s,但对于这样一个简单的问题似乎太冗长了。有更好的方法吗?

Unlike JTextArea, JTextPane has no option to turn line wrapping off. I found one solution to turning off line wrapping in JTextPanes, but it seems too verbose for such a simple problem. Is there a better way to do this?

推荐答案

参见 No Wrap Text Pane 。这是链接中包含的代码。

See No Wrap Text Pane. Here's the code included from the link.

JTextPane textPane = new JTextPane();
JPanel noWrapPanel = new JPanel( new BorderLayout() );
noWrapPanel.add( textPane );
JScrollPane scrollPane = new JScrollPane( noWrapPanel );

这篇关于JTextPane换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆