This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JEditorPane html

 
Alex Wolf
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Alex
 
sasi kala
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

like,

textarea1.append(required text);
editorpane.setText(textarea1.getText());


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

Hope this helps you.

All The Best.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic