I find that a useful way to draw attention to a jcombobox when one wants the user to select from it is to make it drop down at the point it gains focus usually when the previous item has been completed by the user. How can this been done in Java?
You could do:
comboBox.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
comboBox.showPopup();
}
});
You want JComboBox#setPopupVisible
Add in a FocusListener
to monitor for focus gained and you should be right.
Depending on if the combo box is editable or not, you may need to add a focus listener to the editor as well
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With