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.
精彩评论