Code example for JTextComponent

Methods: getSelectedText