File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JEditorPane html Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JEditorPane html" Watch "JEditorPane html" New topic

JEditorPane html

Alex Wolf

Joined: Aug 24, 2004
Posts: 16
hello everyone,

i want to add text to a JEditorPane. this works great:
JEditorPane.setText( "<strong>this is bold text</strong> this is not" );
what about if i want to add text?
JEditorPane.getDocument().insertString( int, "<strong>Bold</strong>plain", AttributeSet );
this just puts "<strong>Bold</strong>plain". how can i format it before it gets added? I dont want to have to use
alltext += "<strong>Bold</strong>plain";
JEditorPane.setText( alltext );

Im guessing its something with EditorKits or HTMLDocuments or something? but I dont understand the documentation.
sasi kala
Ranch Hand

Joined: Dec 17, 2004
Posts: 68
Hi Alex Wolf,

I got the same problem. my solution for it is

each time when you want to add text, just append it to textarea after that read text from textarea and put it in editorpane.


textarea1.append(required text);

so many sites saying that "Editorpane will holds the latest text only".

Hope this helps you.

All The Best.
I agree. Here's the link:
subject: JEditorPane html
Similar Threads
Setting font and Color in body text while sedding Email through Java Code.
Escaping &gt; and &lt: tags in XSL
Need help with JEditorPane
JEditorPane nbsp handling error ?
How to handle nested html tags in XSL?