You can try to center it manually.
Calculate the word's width and calculate the JTextPane's widht. Then get
additional shift and set paragraph's left indent to the shift.
Another potentially better solution would be to use TabStop with
ALIGN_CENTER. So you can define the TabStop with position equals the center
x and set the alignment to be CENTER. Then insert char just before the
You can define
TabSet paragraph attribute. See
public static void setTabSet(MutableAttributeSet a, TabSet tabs)
TabSet has the constructor
public TabSet(TabStop tabs)
Then see TabStop constructor
public TabStop(float pos, int align, int leader)
where you can set center align
Then just call