John Topley's Knowledgebase

Right-Justifying JTextPane Text

Tuesday, 05 August 2003

This Java code right–justifies the text in a Swing JTextPane component.

Download 0024.txt

import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;

SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setAlignment(sas, StyleConstants.ALIGN_RIGHT);
textPane.setParagraphAttributes(sas, false);

top | index | previous | next | comments ()

home | archive | kb | media | about | contact | accessibility
Copyright © 2003 - 2005 John Topley. Made with CityDesk.