M
MikL
Hi all,
I have a Swing UI containing JTextFields. When the user moves the focus
into a JTextField using the keyboard (eg. by pressing TAB), I want to use
selectAll() so that the user can then overwrite the field contents without
messing with the mouse or having to type multiple backspaces or other
keyboard gymnastics. However, I _don't_ want to selectAll() if focus was
moved to the field using the mouse.
Currently I'm looking at monitoring the sequence of FocusListener and
MouseListener events to determine whether the user used the keyboard or
mouse to move focus, but it seems unelegant and relies on eg. mousePressed()
running after requestFocus() and before focusGained(). Is there a better
way to detect how the focus was moved?
Regards,
MikL
I have a Swing UI containing JTextFields. When the user moves the focus
into a JTextField using the keyboard (eg. by pressing TAB), I want to use
selectAll() so that the user can then overwrite the field contents without
messing with the mouse or having to type multiple backspaces or other
keyboard gymnastics. However, I _don't_ want to selectAll() if focus was
moved to the field using the mouse.
Currently I'm looking at monitoring the sequence of FocusListener and
MouseListener events to determine whether the user used the keyboard or
mouse to move focus, but it seems unelegant and relies on eg. mousePressed()
running after requestFocus() and before focusGained(). Is there a better
way to detect how the focus was moved?
Regards,
MikL