How to get selected text in jtextarea

I have jtextarea with some texts. I use java highligher to highlight some texts on this jtextarea. I want to print the contents of this text box in another text box with selected texts. Is it possible? Or is there a way to get only the selected text inside jtextarea?

+2
source share
2 answers

Use the getHighlights () method of your marker. From there, you can get the offsets of the beginning and end of the selection.

+3
source

You can simply query the text area for the selected text using the getSelectedText method.

+2
source

All Articles