# G4P dropList number of elements

**URL:** https://discourse.processing.org/t/g4p-droplist-number-of-elements/2434
**Category:** Libraries
**Created:** [August 7, 2018, 5:28am UTC](https://discourse.processing.org/t/g4p-droplist-number-of-elements/2434 "2018-08-07T05:28:25Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![MxFxM](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@MxFxM](https://discourse.processing.org/u/MxFxM)
#### Post date: [August 7, 2018, 5:28am UTC](https://discourse.processing.org/t/g4p-droplist-number-of-elements/2434/1 "2018-08-07T05:28:26Z")

</div>

Hi,  
the maximum number of elements shown in the dropList (when expanded) seems to be 10.  
Is there a way to increase the number (I want 20 🙂 )?  
Thanks

---

<div class="post-metadata">

### Author: ![EnhancedLoop7](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/enhancedloop7/32/1040_2.png) [@EnhancedLoop7](https://discourse.processing.org/u/EnhancedLoop7)
#### Post date: [August 7, 2018, 3:16pm UTC](https://discourse.processing.org/t/g4p-droplist-number-of-elements/2434/2 "2018-08-07T15:16:28Z")

</div>

Hey, I did a bit of searching and found this specific page on the G4P website: [G4P (GUI for Processing): g4p\_controls.GDropList Class Reference](http://www.lagers.org.uk/g4p/ref/classg4p__controls_1_1_g_drop_list.html#adf42de470eab602aaf15e21a126b763c)

Most specifically:

| g4p\_controls.GDropList.GDropList | ( | PApplet | _theApplet_ , |
| --- | --- | --- | --- |
| | | float | _p0_ , |
| | | float | _p1_ , |
| | | float | _p2_ , |
| | | float | _p3_ , |
| | | int | _viewListMaxSize_ |
| | ) | | |

With a description reading:

> Create a drop down list component with a specified list size.

So I hope this is what you’re looking for? Please try it out and let me know. Thanks!

EnhancedLoop7

---

<div class="post-metadata">

### Author: ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)
#### Post date: [August 7, 2018, 5:46pm UTC](https://discourse.processing.org/t/g4p-droplist-number-of-elements/2434/3 "2018-08-07T17:46:47Z")

</div>

Yes you can set the maximum number of items to be displayed when creating the droplist. Just like this

```auto
import g4p_controls.*;

GDropList dl;

void setup() {
  size(400, 600);
  String[] items = new String[30];
  for (int i = 0; i < items.length; i++) {
    items[i] = "" + (i+1);
  }
  dl = new GDropList(this, 10, 10, 120, 400, 20);
  // ^ number of items to show
  dl.setItems(items, 3); // Start with '4' selected
}

void draw() {
  background(255);
}

```

---

<div class="post-metadata">

### Author: ![MxFxM](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@MxFxM](https://discourse.processing.org/u/MxFxM)
#### Post date: [August 8, 2018, 5:20am UTC](https://discourse.processing.org/t/g4p-droplist-number-of-elements/2434/4 "2018-08-08T05:20:32Z")

</div>

OK first up: I used the G4P GUI builder tool for this because I have a lot of buttons and checkboxes and it’s easier to have them visually layed out for me.

The tool limits me (for whatever reason as I now found out) to 10 lines maximum. That’s why I posted this.

As of now it works fine, thanks to you guys. But I now have to change 2 values of this:

> [@EnhancedLoop7](#):
>
> | g4p\_controls.GDropList.GDropList | ( | PApplet | _theApplet_ , |
> | --- | --- | --- | --- |
> | | | float | _p0_ , |
> | | | float | _p1_ , |
> | | | float | _p2_ , |
> | | | float | _p3_ , |
> | | | int | _viewListMaxSize_ |
> | | ) | | |

namely p3 (height when extended) and _viewListMaxSize_ every time I open and close the tool.

I tried putting the creation of the dropList a second time directly behind the createGUI() but it doesn’t show anything then… :

```auto
createGUI();
datasets_dropList = new GDropList(this, 1460, 40, 420, 660, 20); //660 and 20 are the values I want
datasets_dropList.setItems(loadStrings("list_478498"), 0);
datasets_dropList.setLocalColorScheme(GCScheme.SCHEME_8);
datasets_dropList.addEventHandler(this, "datasets_dropList_click");

```

Is there a way to make it so I don’t have to change the values every time?

---

<div class="post-metadata">

### Author: ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)
#### Post date: [August 8, 2018, 8:39am UTC](https://discourse.processing.org/t/g4p-droplist-number-of-elements/2434/5 "2018-08-08T08:39:41Z")

</div>

> [@MxFxM](#):
>
> The tool limits me (for whatever reason as I now found out) to 10 lines maximum.

I don’t know why I limited it to 10, it probably made sense when I created GUI Builder. I will certainly change it for the next release but that doesn’t help you at the moment.

> [@MxFxM](#):
>
> Is there a way to make it so I don’t have to change the values every time?

Sorry I can’t think of a sensible workaround.

I am assuming you are in the development / testing phases, can you not wait until you are ready to deploy and then modify the code?
