controlP5 Slider and Buttons as arrays

Using controlP5,

I need to create 40 sliders and 40 buttons, I use to use Delphi and could create an array of scrollbars with associated buttons. Can I do the same with processing, if so, can anyone could shed some light onto how to go about it.

The slider positions and button captions need to be set both manually and at runtime. The button captions will reflect the scroll bar positions. some other code will also change the slider positions.

So I would in code set the position of a scroll bar something like:
scrollbar(X).position=328
button.caption= scrollbar(X).position

Trying to avoid creating 40 sets of these.

Slider f1 = controlP5.addSlider("SLIDR1")
.setRange(SLIDRmin,255)
.setValue(SLIDRdefault)
.setPosition(SLIDRleftposition,SLIDRtopY)
.setSize(SLIDRwidth,SLIDRheight)
.setColorActive(0xffffffff)
.setLabelVisible(false);
f1.setSliderMode(Slider.FLEXIBLE)
;

bt1 = controlP5.addButton("bt1");
bt1.setPosition(SLIDRleftposition, SLIDRheight+SLIDRtopY+2);
bt1.setSize(SLIDRwidth, SLIDRwidth);
bt1.setFont(createFont("SansSerif", 14));
bt1.setColorCaptionLabel(#ffffff);
bt1.setColorBackground(#000000);
bt1.getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER)
;    

There is another recent post by Darthbray that might be worth your while:

Rather than using a library such as controlP5, Darthbray wrote his/her own Button class. An array is made to hold 50 of these, which are created (and added to the array) a little bit later.

Similar to Darthbray’s Button class, you could write your own SliderSet class that groups together a slider and its associated buttons.