# ComboBox.addItem() exception thrown

**URL:** <https://forum.juce.com/t/combobox-additem-exception-thrown/59519>\
**Category:** General JUCE discussion\
**Created:** [January 13, 2024, 11:23pm UTC](https://forum.juce.com/t/combobox-additem-exception-thrown/59519 "2024-01-13T23:23:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaulPulsar](https://avatars.discourse-cdn.com/v4/letter/r/b9e5f3/32.png) [@RaulPulsar](https://forum.juce.com/u/RaulPulsar)\
**Post date:** [January 13, 2024, 11:23pm UTC](https://forum.juce.com/t/combobox-additem-exception-thrown/59519/1 "2024-01-13T23:23:28Z")

</div>

This must be silly but I’m lost.  
I just have declare a ComboBox:

```auto
private:
    ComboBox filterTypeMenu;

```

And added

```auto
void CircularAudioBufferAudioProcessorEditor::paint (juce::Graphics& g)
{
   filterTypeMenu.addItem("Lowpass", 1);
    filterTypeMenu.addItem("HighPass", 2);
    filterTypeMenu.setText("Filter Type:", dontSendNotification);
    addAndMakeVisible(filterTypeMenu);
}

```

But after building it myProject.exe triggers a breakpoint in this bit of code from the comboBox:

```auto
// you shouldn't use duplicate item IDs!
    jassert (getItemForId (newItemId) == nullptr);

```

I don’t understand why this happens if no comboBox ID is duplicated.

Someone knows why this could be happening?

---

<div class="post-metadata">

**Author:** ![cpr2323](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/cpr2323/32/18682_2.png) [@cpr2323](https://forum.juce.com/u/cpr2323)\
**Post date:** [January 14, 2024, 2:28am UTC](https://forum.juce.com/t/combobox-additem-exception-thrown/59519/2 "2024-01-14T02:28:55Z")

</div>

You should not be doing this in ‘paint’. It is getting called repeatedly, and it is adding the items each time. So, on the second call you ARE duplicating the IDs. All of that code should probably go in the constructor

---

<div class="post-metadata">

**Author:** ![RaulPulsar](https://avatars.discourse-cdn.com/v4/letter/r/b9e5f3/32.png) [@RaulPulsar](https://forum.juce.com/u/RaulPulsar)\
**Post date:** [January 14, 2024, 2:02pm UTC](https://forum.juce.com/t/combobox-additem-exception-thrown/59519/3 "2024-01-14T14:02:48Z")

</div>

You are right. Thanks so much

Raul
