This week's book giveaway is in the Agile forum.
We're giving away four copies of The Software Craftsman and have Sandro Mancuso on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTextPane and Justified Paragraphs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextPane and Justified Paragraphs" Watch "JTextPane and Justified Paragraphs" New topic

JTextPane and Justified Paragraphs

Stephan Bardubitzki

Joined: Dec 26, 2005
Posts: 29
Hi all,

I have to display some formatted paragraphs in a JTextPane. Each paragraph should have a header in bold letters and following some justified text. I can change font style and color, but the justified alignment won't happen with this code:

Any suggestions to solve the task are highly appreciated.

Thanks in advance.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Stephan Bardubitzki

Joined: Dec 26, 2005
Posts: 29
Thank you very much Craig, works like a charm.
Hmmm... the last line of the paragraph should be aligned left. Any ideas?
Sorry, I'm not very familiar with text components.

jQuery in Action, 2nd edition
subject: JTextPane and Justified Paragraphs