ai_chien
asked on
Focus Traversing with user action "ENTER"
Hi,
I am trying to find a way to allow users keying in fields by traversing via TAB key or ENTER key from keyboard. TAB working fine from fields to fields but users need to have ENTER for traversing as well. I found a good reference here in EE but some of the methods have deprecated.
I found these from other resources, but it claims to be 'unchecked or unsafe operations'.
<code>
Set set = new HashSet(
KeyboardFocusManager.getCu rrentKeybo ardFocusMa nager().ge tDefaultFo cusTravers alKeys(
KeyboardFocusManager.FORWA RD_TRAVERS AL_KEYS));
set.clear(); // Call clear() if you want to eliminate the current key set
set.add(KeyStroke.getKeySt roke("ENTE R"));
KeyboardFocusManager.getCu rrentKeybo ardFocusMa nager().se tDefaultFo cusTravers alKeys(
KeyboardFocusManager.FORWA RD_TRAVERS AL_KEYS, set);
</code>
I try to apply above for my code but I wasn't sure if its working and how should I be traverse from 1 field to another. Any advice is appreciated. Thanks.
I am trying to find a way to allow users keying in fields by traversing via TAB key or ENTER key from keyboard. TAB working fine from fields to fields but users need to have ENTER for traversing as well. I found a good reference here in EE but some of the methods have deprecated.
I found these from other resources, but it claims to be 'unchecked or unsafe operations'.
<code>
Set set = new HashSet(
KeyboardFocusManager.getCu
KeyboardFocusManager.FORWA
set.clear(); // Call clear() if you want to eliminate the current key set
set.add(KeyStroke.getKeySt
KeyboardFocusManager.getCu
KeyboardFocusManager.FORWA
</code>
I try to apply above for my code but I wasn't sure if its working and how should I be traverse from 1 field to another. Any advice is appreciated. Thanks.
check this link, http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.