开发者

Setting line space for a JTextarea

开发者 https://www.devze.com 2023-02-25 08:54 出处:网络
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?

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.


There is no simple way to do this. Per the Swing Tutorial (emphasis mine):

If you want the text area to display its text using multiple fonts or other styles, you should use an editor pane or text pane.

That said, the source for JTextArea shows that it's not declared final. If you really want to change the spacing, you could create a custom subclass. That wouldn't be trivial, though.

0

精彩评论

暂无评论...
验证码 换一张
取 消