I have this code that is suppose to append text to a JTextPane, using the Document method insertString(). I can't seem to get the attribute argument right, so maybe one of you can point me in the right direction...

Here is the one line of code giving me problems, just at the attribute argument


doc == myTextPane.getDocument

last pos == myTextPane.getSelectionEnd()

and s == the string to be inserted

It's just the atrributes part I can't seem to get working..

Any ideas?

Recommended Answers

All 2 Replies

Hi everyone,

Try this

doc.insertString(TextPane.getCaretPosition(), s, null);

This seems to always work for me

Richard West

Thank you, this worked perfectly!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.