Simple jButton question.



I want a jButton to replace a selected text with the new text in a
JTextPane. How can i do that?

JTextPane p = new JTextPane;
JButton b = new JButton("Replace Text");

assume the user has selected a text... now what do i do?

b.setActionCommand( ? );

Where is a reference for all setActionCommand arguments? or can i pass
a function instead of a string?

b.setActionCommand( p.replaceSelection("New Text") ) ?

obviously, this will not work...

any hints?

.