posted 11 years ago
Welcome to the Ranch.
AFAIK there is no simple approach to solve this as there is no listener that responds to text selections.
You could however add a CaretListener and whenever the caret is moved check the JTextField to see if any of the text is selected (getSelectedText() returns null if nothing is selected) and if the highlighted state has changed set the button state accordingly.