I need to allow the user to highlight text (select a range with the mouse), then I want to give them the ability to apply some setting to that text form a drop down right click menu.
I know the latter part. But how do I get which text string is selected from a Text Area in JavafX?
Also, would I be able to apply different styles to different strings?
Use
getSelectedText()
to get the selected text.The answer to your second question is yes.
The
getSelectedText()
method can be used like I have done here:Once you launch this application, it shows a
TextArea
with some text (Text Sample
). I selected some part of the text and did a right click. It printed the selected text. Does this fit your requirement?