Reputation: 2165
I have a jcombobox in my application. and i want it to support multiple selection (like it do in a jlist). is there any code example?
Upvotes: 10
Views: 20858
Reputation: 8227
I think it's not possible, unless you use a JList, like you said.
The JComboBox API reports:
The user can select a value from the drop-down list, which appears at the user's request.
And a JComboBox tutorial:
Lists are not terribly attractive, but they're more appropriate than combo boxes when the number of items is large (say, over 20) or when selecting multiple items might be valid.
Update:
I reviewed this answer, because actually it's "possible" to do that using a ListCellRenderer, adding a checkbox to each item. Please consider this answer to implement this "solution".
However, I don't think it's a good idea for the following reasons:
Upvotes: 8
Reputation: 1
It's not quite impossible but there's a lot of work to do to get the job done. You'll need to create your own classes to extend/implement all of these:
Upvotes: 0