inserting HTML with Editorkit does nothing!

Hi.

Please have a look at the following code-snippet:// jtpMain is a JTextPane containing some text

HTMLEditorKit htmlKit =new HTMLEditorKit();

HTMLDocument htmlDoc = (HTMLDocument) jtpMain.getStyledDocument();

jtpMain.setEditorKit(htmlKit);

String t = htmlDoc.getText(0, htmlDoc.getLength());

System.out.println("styled doc contains:" + t);

htmlKit.insertHTML(

htmlDoc,

jtpMain.getCaretPosition(),

"<b>Hello World!</b>",

0, 0,

HTML.Tag.B

);

System.out.println("html inserted.");

I get both the messages (System.out.println) and no Exception is thrown. But this should insert the bold String 'Hello World!' into the existing document. Anyhow there's no result. The text is still the same as before, nothing has changed. Does anyone know why?

cheers,

kelysar

[1027 byte] By [kelysara] at [2007-9-28 6:47:39]
# 1
kelysara at 2007-7-9 17:58:56 > top of Java-index,Archived Forums,Java Programming...
# 2
You may try another method inherited from JEditorPane class -- setText(String content). The string should be in form of HTML specification.good luck.
joneytana at 2007-7-9 17:58:56 > top of Java-index,Archived Forums,Java Programming...
# 3
Thanks for the advice. By now I solved it otherwise. But since you're the only one who answered, you'll get the dukes ;o)cheers,kelysar
kelysara at 2007-7-9 17:58:56 > top of Java-index,Archived Forums,Java Programming...
# 4
Was your solution better? If so, let us know what it was in case someone else comes along with the same problem.
YATArchivista at 2007-7-9 17:58:56 > top of Java-index,Archived Forums,Java Programming...