Java tutorial
import javax.swing.JTextArea; import javax.swing.text.JTextComponent; public class Main { public static void main(String[] argv) { JTextComponent c = new JTextArea(); // Get text inside selection c.getSelectedText(); } }