JTextPane with RTF Contentype - Aligment center and Right
Hello,
I use a JTextPane to showing a RTF-Text.
with following code:
String text = "{\\rtf1\\ansi{\\fonttbl\\f0\\fnil Monospaced;\\f1\fnil Tahoma;\\f2\\fnil Verdana;" +
"\\f3\\fnil Arial;}{\\colortbl\\red0\\green0\\blue0;\\red255\\green0\\blue0;\\red0\\green0\\blue255;}\\widowctrl" +
"\\li0\\ri0\\fi0\\tx510\\tx1020\\tx1530\\tx2040\\tx2550\\tx3060\\tx3570\\tx4080\\tx4590\\tx5100\\tx5610\\tx6120\\tx6630\\tx7140\\tx7650\\tx8160\\tx8670\\tx9180\\tx9690\\tx10200\\tx10710\\tx11220\\tx11730\\tx12240\\tx12750\\tx13260\\tx13770\\tx14280\\tx14790\\tx15300\\tx15810\\tx16320\\f2\\fs24\\i0\\b0\\ul0\\cf1 Guten Morgen\\par" +
"\\par\\pard\\tx510\\tx1020\\tx1530\\tx2040\\tx2550\\tx3060\\tx3570\\tx4080\\tx4590\\tx5100\\tx5610\\tx6120\\tx6630\\tx7140\\tx7650\\tx8160\\tx8670\\tx9180\\tx9690\\tx10200\\tx10710\\tx11220\\tx11730\\tx12240\\tx12750\\tx13260\\tx13770\\tx14280\\tx14790\\tx15300\\tx15810\\tx16320\\f3\\fs32\\b\\cf2 Alle miteinander\\par" +
"\\pard\\li0\\ri0\\fi0\\fs24\\i0\\b0\\ul0\\par}";
StyledDocument doc = this.getStyledDocument();
InputStream os = new ByteArrayInputStream(text.getBytes());
this.getEditorKitForContentType("text/rtf").read(os, doc, 0);
os.close();
The RTF text above is right aligment. But the JTexPane display the text in left aligment.
How can I get the JTextPane to display the RTF text correctly ? There are a workaround or is is the limit of the RTFEditorKit
I hope to get an answer.
many thanks