Content centered in JEditorPane! Why?

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());
}

....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top