Have you added the focus listener to the JTextField? If so, can you show us the code of the focusGained method?
I've created the following little
SSCCE which selects all text when the focus is gained and deselects all text when the focus is lost again:
This code is working just fine for me.