I created a form in swing/jdk1.4 and I want to set tabindex or setFocus on pressing tab key to move cursor next field.
Please help and give any suggestions.
Printable View
I created a form in swing/jdk1.4 and I want to set tabindex or setFocus on pressing tab key to move cursor next field.
Please help and give any suggestions.
Let's say that you have a JLabel and a JTextField. You can create a mnemonic for the label that when pressed will jump to the text field. setDisplayedMnemonic(char c) can be used on the JLabel and setLabelFor(Component c) can be used on the JTextField.
The other way would be to either set the nextFocusableComponent property or call the requestFocus() on the component itself.
If all you have is JTextFields and JLabels then the focus manager should just tab to the next JTextField when the tab key is pressed.