N
Nico
Hi, I am writing on a little HTML-editor for my CMS. For that purpose I
load text from a hidden form into my applet and add the text to the
HTMLDocument using setInnerHTML() with the BODY-Tag as starting
Element. But when the EditorPane shows up the Text is centered in the
JEditorPane and wrapped at each closing html-tag. When I change to the
code-view and then back to the html-view everything is fine. When
changing between the views I just copy the content of the html pane to
the plain text pane using the getText() and setText() Function and vice
versa. What might be the Problem? I can't see any Problems with the
HTML code.
Thank you for your help! Nico
Code:
....
EditorKit editorKit = pane.getEditorKitForContentType ("text/html");
EditorKit txtEditorKit = txtPane.getEditorKitForContentType
("text/plain");
pane.setEditorKit(editorKit);
txtPane.setEditorKit(txtEditorKit);
HTMLDocument doc = (HTMLDocument)pane.getDocument();
Element startElem = findSuccElement(HTML.Tag.BODY.toString(),
doc.getDefaultRootElement()); //getting the BODY-tag
try {
doc.setPreservesUnknownTags(false);
doc.setInnerHTML(startElem, itext.get()); //itext: the text from the
form
} catch (..) {..}
....
public void HTMLToTxt() { //Copying the text from the HTMLPane to the
txtPane
itext.update(pane.getText());
txtPane.setText(itext.get());
}
....
load text from a hidden form into my applet and add the text to the
HTMLDocument using setInnerHTML() with the BODY-Tag as starting
Element. But when the EditorPane shows up the Text is centered in the
JEditorPane and wrapped at each closing html-tag. When I change to the
code-view and then back to the html-view everything is fine. When
changing between the views I just copy the content of the html pane to
the plain text pane using the getText() and setText() Function and vice
versa. What might be the Problem? I can't see any Problems with the
HTML code.
Thank you for your help! Nico
Code:
....
EditorKit editorKit = pane.getEditorKitForContentType ("text/html");
EditorKit txtEditorKit = txtPane.getEditorKitForContentType
("text/plain");
pane.setEditorKit(editorKit);
txtPane.setEditorKit(txtEditorKit);
HTMLDocument doc = (HTMLDocument)pane.getDocument();
Element startElem = findSuccElement(HTML.Tag.BODY.toString(),
doc.getDefaultRootElement()); //getting the BODY-tag
try {
doc.setPreservesUnknownTags(false);
doc.setInnerHTML(startElem, itext.get()); //itext: the text from the
form
} catch (..) {..}
....
public void HTMLToTxt() { //Copying the text from the HTMLPane to the
txtPane
itext.update(pane.getText());
txtPane.setText(itext.get());
}
....