This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman 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 Building Microservices this week in the Design 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.

I agree. Here's the link:
subject: JTextPane and Justified Paragraphs
It's not a secret anymore!