JTextArea中的行间距

Sur*_*dhi 6 java line spacing jtextarea

看来我当前的JTextArea实例的行间距约为1或1.5.任何人都可以告诉我如何更改JTextArea实例中的行间距?

Tom*_*Tom 11

进行谷歌搜索建议您应该使用JTextPane,特别是setParagraphAttributes位于此处.

获得AttributeSet所需的方法如下:

MutableAttributeSet set = new SimpleAttributeSet();
StyleConstants.setLineSpacing(set, /* your spacing */);
Run Code Online (Sandbox Code Playgroud)

现在只是传递setsetParagraphAttributes方法.

希望这可以帮助.