Home arrow static arrow Java Programming [Archive] - Row distance, JTextPane
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Row distance, JTextPane
This topic has 3 replies on 1 page.

Posts:38
Registered: 2/12/04
Row distance, JTextPane  
Aug 4, 2004 7:08 AM



 
Does anyone know if it is possible to specify a certain distance between rows in a JTextPane? I would like to be able to increase the distance between rows in my JTextPane... I have been reading the API on TextComponents but not being able to find anything about this...

Thankful for response
Fred
 

Posts:31,095
Registered: 4/30/99
Re: Row distance, JTextPane  
Aug 4, 2004 8:26 AM (reply 1 of 3)



 
The "leading" of a font is the distance between the bottom of the descenders to the top of the next line. So it sounds like you need to use a font with a larger leading. Scanning the API docs for Font, I don't right away see how to do that, though. There's a bunch of deriveFont() methods that allow you to scale and resize a font, which isn't quite what you want. There's a deriveFont(Map) method that allows you to create a new font with certain "attributes" set, but what those attributes might be is not documented as far as I can see. You could hack around with that for a bit -- I see there's a getAttributes() method that shows you what the "attributes" are for a particular font.

PC²
 

Posts:24,517
Registered: 98-02-27
Re: Row distance, JTextPane  
Aug 4, 2004 9:18 PM (reply 2 of 3)



 
On an empty document do something like:

MutableAttributeSet standard = new SimpleAttributeSet();
StyleConstants.setLineSpacing(standard, 0.5f);
document.setParagraphAttributes(0, 0, standard, true);
 

Posts:38
Registered: 2/12/04
Re: Row distance, JTextPane  
Aug 5, 2004 1:58 AM (reply 3 of 3)



 
Thanks for the replies
 
This topic has 3 replies on 1 page.