I'm aware of JList
and JComboBox
. I need the combo box drop down functionality with multiple selection functionality that JList
provides.
This is because the contents of the list are too huge to be displayed using a simple list. I also need to select multiple items, otherwise I would have been content with JComboBox
.
Any suggestions?
Windows: We need to hold down the CTRL button to select multiple options. Mac: We need to hold down the command button to select multiple options.
Create a Dropdown Menu Using JComboBox in Java swing 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.
Select the items in ComboBox You can select multiple items at one shot in MultiSelectionComboBox by using ShowCheckBox and DisplayMode property.
To select multiple options in a drop-down list, use the multiple properties. It allows you to select more than one option while pressing CTRL key.
When using multi-select, it's better to use a list than a combo box. As GUI metaphors go, people expect a combo box to be single select, whereas lists can be either.
the contents of the list are too huge to be displayed using a simple list
Place the JList
in a JScrollPane
. You can call setVisibleRowCount(int) on the JList
to specify how many rows at a time should be shown.
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