Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line-Spacing in JTextArea

It seems my current JTextArea instance is having line-spcing about 1 or 1.5. Can anybody tell me how to change the line-spacing in JTextArea instance?

like image 702
Surjya Narayana Padhi Avatar asked Dec 07 '09 03:12

Surjya Narayana Padhi


1 Answers

Doing a google search suggests you should be using JTextPane and in particular the setParagraphAttributes located here.

The way to get the AttributeSet you need is as follows:

MutableAttributeSet set = new SimpleAttributeSet();
StyleConstants.setLineSpacing(set, /* your spacing */);

Now just pass in set to the setParagraphAttributes method.

Hope this helps.

like image 56
Tom Avatar answered Sep 19 '22 16:09

Tom