简体   繁体   中英

Is there a way to change the JComboBox's items focus?

I can change the item's focus by pressing the arrow keys on the keyboard or by moving the mouse over it. Is there a programmatic way to move the focus around the items?

You can simply set the selected item. Optionally, you can show the dropdown list:

comboBox.requestFocus();
comboBox.showPopup();
comboBox.setSelectedIndex(selectedIndex);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM