ControlP5: RadioButtons - how to style each button individually?

edited April 2014 in Library Questions

I can style the whole set of RadioButtons, but some text labels are longer than others, so it ends up looking not-so-great. Is there a way to style each button individually? For loops seem to mess up the RadioButton code, ends up getting errors saying "name of RadioButton"/"name of Item" already exists.

Here's the code I'm currently using:

import controlP5.*;
ControlP5 cp5Parts;

setup() {
size(1400, 800, P3D);
cp5Parts = new ControlP5(this);

  ControlFont cf18 = new ControlFont(createFont("Arial",18));

Parts = cp5Parts.addRadioButton("PartsButton")
         .setPosition(100, 107)
         .setSize(150, 20)
         .addItem("Fat Body[F]",4)
         .addItem("PSG[F]", 8)
         .addItem("Fat Body[M]",13)

  for(Toggle tt:Parts.getItems()) {
       tt.captionLabel().style().moveMargin(0, 0, 0, -150);
       tt.captionLabel().style().movePadding(0, 0, 0, 0);

void draw() {

// Other stuff 




  • Hi, there is no out of the box solution to do what you are looking for, maybe centering the label and adding some spacing helps?

  • edited April 2014

    @sojamo How would I center the label?

    ... Never mind, I guess putting spaces in the label names. Not exactly ideal, but it will have to do I guess.

Sign In or Register to comment.