Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Equivalent of setText for JTextPane's  RSS feed

 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the equivalent of setText for JTextPane. Is there a way to erase all the data in the JTextPane...
Example:

I want to know the equivalent to that in JTextPane.
I am using SimpleAttributeSet and InsertStrings right now.
For the JTextPane, I am doing thing like:

and:

Thanks,
John Price aka cc11rocks
 
Rob Camick
Ranch Hand
Posts: 2800
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried and what problems are you having?
 
Rob Spoor
Sheriff
Posts: 21088
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTextPane extends JEditorPane which has a setText method. Another option that will work for any text component is get its Document and remove all data from it:
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. I used the "remove". It worked!
Thanks,
John Price aka cc11rocks
 
Rob Camick
Ranch Hand
Posts: 2800
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And why would you not use setText(...) since you already know that method?

JTextPane extends JEditorPane which has a setText method.


So much for forcing the poster to think a little before posting a question. Why would one text component have a setTest() method but not the others?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!