Is it possible to determine when a user clicks on a JComboBox to drop down the list of items in it? I just want to capture this event, not when an item is selected from the list.
Many thanks,
Andez
Create a Dropdown Menu Using JComboBox in Javaswing package and is used to show a dropdown list in an interface. Below, we first create the array of options to display in the dropdown list. JComboBox is a component and needs a frame to reside, so we create a JFrame object.
A JComboBox is a component that displays a drop-down list and gives users options that we can select one and only one item at a time whereas a JList shows multiple items (rows) to the user and also gives an option to let the user select multiple items.
JComboBox is a part of Java Swing package. JComboBox inherits JComponent class . JComboBox shows a popup menu that shows a list and the user can select a option from that specified list . JComboBox can be editable or read- only depending on the choice of the programmer .
You can use JComboxBox#addPopupMenuListener(PopupMenuListener listener)
You can use a PopupMenuListener to determine when the drop down is about to open. Add it using the: addPopupMenuListener-Method.
http://download.oracle.com/javase/6/docs/api/javax/swing/event/PopupMenuListener.html
Use this method
void popupMenuWillBecomeVisible(PopupMenuEvent e)
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