我想要的时候:
comboBox.getSelectedIndex() == 1
然后系统焦点应设置为我的textField1
。
这是我的代码:
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == comboBox) {
if (comboBox.getSelectedIndex() == 1) {
// set focus to textField1
}
}
}
答案 0 :(得分:1)
component.requestFocusInWindow();
答案 1 :(得分:0)
尝试textField1.requestFocus();
答案 2 :(得分:-1)
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == comboBox) {
if (comboBox.getSelectedIndex() == 1) {
// set focus to textField1
textField1.requestFocus();
}
}
}