> how can i set right alignment of jtextpane?
Try the following:
JTextPane edit=new JTextPane();
try {
SimpleAttributeSet attrs=new SimpleAttributeSet();
StyleConstants.setAlignment(attrs,StyleConstants.ALIGN_RIGHT);
StyledDocument doc=(StyledDocument)edit.getDocument();
doc.insertString(0,"test",attrs);
doc.setParagraphAttributes(0,doc.getLength()-1,attrs,false);
}
catch (Exception ex) {
ex.printStackTrace();
}
That came from
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=390611