0

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
        }
    }
}
Sajad
  • 2,273
  • 11
  • 49
  • 92

3 Answers3

1
component.requestFocusInWindow();
camickr
  • 321,443
  • 19
  • 166
  • 288
0

Try textField1.requestFocus();

Sandhu Santhakumar
  • 1,678
  • 1
  • 13
  • 24
-1
@Override
public void actionPerformed(ActionEvent e) {
    if (e.getSource() == comboBox) {
        if (comboBox.getSelectedIndex() == 1) {

            // set focus to textField1
            textField1.requestFocus();
        }
    }
}
Phelion
  • 23
  • 5