I am having trouble with getting using setSelectionStart and setSelection end on a JTextField and on a JTextArea.
For the JTextFields, I click the left button on a mouse, and the program will highlight the word that the mouse is in. This works fine.
But if I use the right mouse button expecting the same result, the word is selected as I can use System.out.println to show the word on the console, but the word is not highlighted in the JTextField. Also, this is only when the right click is the first click into that component. What I mean is that if I left click into the component, and then right click, it works fine. How can I get this to work if the right click is the first click into the component?
For the JTextArea, I have a popup that shows up for the user to select a "Copy All" option. This should highlight all the text and copy the contents to the clipboard. The contents are copied to the clipboard but they are not highlighted. Please could someone give me some help to get this highlighted.