1.
JTextComponent的方法:
public String getSelectedText()
Returns the selected text contained in this TextComponent. If the selection is null or the document empty, returns null.
Returns:
the text
Throws:
IllegalArgumentException - if the selection doesn't have a valid mapping into the document for some reason
2.
JTextComponent:
public void select(int selectionStart, int selectionEnd)
Selects the text between the specified start and end positions.