Forums Register Login

Equivalent of setText for JTextPane's

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
What have you tried and what problems are you having?
+Pie Number of slices to send: Send
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:
+Pie Number of slices to send: Send
Thank you very much. I used the "remove". It worked!
Thanks,
John Price aka cc11rocks
+Pie Number of slices to send: Send
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?
this llama doesn't want your drama, he just wants this tiny ad for his mama
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2531 times.
Similar Threads
How do I have a multicolored text in JTextArea? (VERY URGENT )
Problems printing text in JTextPane
setting focus on the appended text in JTextArea
How to insert HTML content directly in code from JEditorPane ?
Unicode equivalent for <br>. Any idea?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:06:16.