设置 JTextarea 的行间距
我的 textArea 行之间的默认间距太笨拙了。我想增加行与行之间的行距。有没有办法在文本区域中实现此目的?
PS:我知道可以使用 StyledDocument
和 STyledConstants 为 JTextPane
设置行距。我的范围仅限于 TextArea,我不想用文本窗格替换我的 textarea,因为它会弄乱项目中的一些其他功能依赖项。
The default spacing between the lines of my textArea is too clumsy. I would like to increase the line spacing between the lines. Is there a way to achieve this for a textarea?
PS: I know that line spacing can be set for a JTextPane
with StyledDocument
and STyledConstants. My scope is limited to TextArea only and I would rather not prefer to replace my textarea with a textpane as it would mess up with some other functional dependencies in the project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有简单的方法可以做到这一点。根据 Swing 教程(重点是我的):
也就是说,
JTextArea
的源代码显示它未声明为final
。如果您确实想要更改间距,您可以创建一个自定义子类。不过,这并不是一件小事。There is no simple way to do this. Per the Swing Tutorial (emphasis mine):
That said, the source for
JTextArea
shows that it's not declaredfinal
. If you really want to change the spacing, you could create a custom subclass. That wouldn't be trivial, though.