This week's book giveaway is in the Java in General forum. We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line! See this thread for details.
I am able to change attributes to JTextPane but unable to align the text. I used DefaultStyledDocument during creation of JTextPane and uses insertString method as explained in usage of TextCmponents at sun site. I used setPreferredSize() method of JTextPane.