G
Gerrit Hulleman
I have created an HTML editor applet using the JEditorpane. But there are
some random features. Most of the time the applet runs fine, but often it
shows odd behaviour.
Sometimes, the applet can be used, but it fails to go to plain text mode
using the code below. Also, a break tag (amongst other things) can no longer
be inserted. Using system.out I can confirm that all the code is processed
and no exceptions are thrown. Clearing the cache and reloading the applet
results in the correct working yet again.
Is this a bug do to the current developement state of the jeditorpane?
Gerrit
switch to plain text mode:
String htmltext = htmledit.getEditor().getText();
htmledit.getEditor().setEditorKit(htmledit.getEditor().getEditorKitForConten
tType("text/plain"));
htmledit.getEditor().setText(htmltext);
Inserting a <br> tag:
if (ChangeEditorType.getInstance(htmledit).isHTMLstate()){
try {
HTMLEditorKit kit = (HTMLEditorKit) htmledit.getEditor().getEditorKit();
HTMLDocument doc = (HTMLDocument) htmledit.getEditor().getDocument();
kit.insertHTML(doc, htmledit.getEditor().getCaretPosition(), "<br>", 0,
0, HTML.Tag.BR);
} catch (Exception e) { .... }
} else {
//in text state
.........
}
some random features. Most of the time the applet runs fine, but often it
shows odd behaviour.
Sometimes, the applet can be used, but it fails to go to plain text mode
using the code below. Also, a break tag (amongst other things) can no longer
be inserted. Using system.out I can confirm that all the code is processed
and no exceptions are thrown. Clearing the cache and reloading the applet
results in the correct working yet again.
Is this a bug do to the current developement state of the jeditorpane?
Gerrit
switch to plain text mode:
String htmltext = htmledit.getEditor().getText();
htmledit.getEditor().setEditorKit(htmledit.getEditor().getEditorKitForConten
tType("text/plain"));
htmledit.getEditor().setText(htmltext);
Inserting a <br> tag:
if (ChangeEditorType.getInstance(htmledit).isHTMLstate()){
try {
HTMLEditorKit kit = (HTMLEditorKit) htmledit.getEditor().getEditorKit();
HTMLDocument doc = (HTMLDocument) htmledit.getEditor().getDocument();
kit.insertHTML(doc, htmledit.getEditor().getCaretPosition(), "<br>", 0,
0, HTML.Tag.BR);
} catch (Exception e) { .... }
} else {
//in text state
.........
}