Hi,

I have to display a JCombobox which contains JCheckBox(containing a single character) as its elements. Combobox has to allow multiple checkbox selection.

When the selection is over, combobox has to display the selected checkbox values.

Thanks in advance,
Sagar

Firstly a combo box would allow you to choose one of several choices so putting check boxes inside it which themselves are used as multiple select components would not be a good option. You could use a list box instead which itself will give you the option of selecting several options within the list so may not not have to worry about putting the check boxes in it.

Firstly a combo box would allow you to choose one of several choices so putting check boxes inside it which themselves are used as multiple select components would not be a good option. You could use a list box instead which itself will give you the option of selecting several options within the list so may not not have to worry about putting the check boxes in it.

But the requirement is that way... i need to put checkbox inside combo..... and later this will be placed in a table.
Plz give me some suggestion for this.

The addItem method of JComboBox takes an Object as an input so you could pretty much try adding JCheckBox to it.

The addItem method of JComboBox takes an Object as an input so you could pretty much try adding JCheckBox to it.

ok....will try this, let's see what happens

ComboBox will select only one item at the time and checkBoxes are used when user is allowed to select multiple items which contradicts the use of ComboBox.

I think the initiator needs to rethink about the use of checkbox in comboBox.

JComboBox only displays the results from a call to the object's toString() method. I suppose you have to alter the renderer that the combobox uses to display the items. Have a look at this link http://forums.sun.com/thread.jspa?forumID=57&threadID=5198095

ComboBox will select only one item at the time and checkBoxes are used when user is allowed to select multiple items which contradicts the use of ComboBox.

I think the initiator needs to rethink about the use of checkbox in comboBox.

All this was already said. Read the previous posts before posting yours.

Yes, you can do it with a custom renderer - I've dome something similar myself.

Yes, you can do it with a custom renderer - I've dome something similar myself.

Hi... am doing this using renderers and editors...its half done. Its giving some stackoverflow error.
hey plz help me in doing this.

Print out the entire error trace for us here.

Print out the entire error trace for us here.

Error:
java.lang.StackOverflowError
java.lang.StackOverflowError
java.lang.StackOverflowError

C'mon now I said we would need the entire stack trace, line number, file etc. Also post the relevant code with that without which we ould have no clue whatsover.

C'mon now I said we would need the entire stack trace, line number, file etc. Also post the relevant code with that without which we ould have no clue whatsover.

This problem has been sorted out. Now am able to put checkbox in combo but not able to select the checkbox.

You're probably going to have to dig into the event processing code of the combo and forward the appropriate events along to the checkbox that is being selected.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.