Question

I want when :

comboBox.getSelectedIndex() == 1

Then system focus should set to my textField1 .

this is my code:

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getSource() == comboBox) {
        if (comboBox.getSelectedIndex() == 1) {

            // set focus to textField1
        }
    }
}
Was it helpful?

Solution

component.requestFocusInWindow();

OTHER TIPS

Try textField1.requestFocus();

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getSource() == comboBox) {
        if (comboBox.getSelectedIndex() == 1) {

            // set focus to textField1
            textField1.requestFocus();
        }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top