views:

212

answers:

1

Hi Geeks,

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?

+1  A: 

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.

Tom