There is any way to automatically by default select text in JTextField and JTextArea when focusGained event occurs?
There is any way to automatically by default select text in JTextField and JTextArea
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You just said how to do it — focusGained event of a FocusListener.
You can then get the JComponent whose focus has been gained via FocusEvent’s
getSource()method and then call theselectAll()method on it.Something like: