Hi, find a solution to your problem below. When posting code, it helps to post a working sketch so it is easier to copy/paste/run and identify the problem. I have included comments in the sketch below guiding you through the steps required to disable the caption labels of a radioButton.
- import controlP5.*;
- ControlP5 controlP5;
- void setup() {
- size(400,400);
- // using controlP5 2.0.4 processing 2.0b7 (this should also work for 1.5.1)
- controlP5 = new ControlP5(this);
-
- RadioButton[] RadBut_analog = new RadioButton[6];
- int rouge = color(255,0,0);
- for (int i=0; i<6; i++) {
- RadBut_analog[i] = controlP5.addRadioButton("RA"+i,20,40+(i*35));
- RadBut_analog[i]. setItemHeight(15);
- RadBut_analog[i]. setItemWidth(5);
- RadBut_analog[i].setItemsPerRow (0);
- RadBut_analog[i].setSpacingColumn(120);
- RadBut_analog[i].setColorLabel(color(0xffffffff));
-
- RadBut_analog[i].addItem("in "+i, 1);
- // after adding an item, the item is stored inside a List.
- // in order to access the item we need to get the item from the List
- // with yourRadioButton.getItem(indexOfItem)
- // since we have just added the first item, this item can be found at
- // index = 0 of the list. Now, getItem returns an Controller of type
- // Toggle, so we can access the caption label with getCaptionLabel() and
- // set its visibility to false.
- RadBut_analog[i].getItem(0).getCaptionLabel().setVisible(false);
- RadBut_analog[i].addItem("out "+i, 2);
- // after adding the second item, we repeat the procedure from above
- // to make the caption label invisible
- RadBut_analog[i].getItem(1).getCaptionLabel().setVisible(false);
-
- RadBut_analog[i].setId(10+i);
- RadBut_analog[i].setColorBackground(color(192,192,192)); // fixe couleur fond
- RadBut_analog[i].setColorActive(rouge);
-
- }
- }
- void draw() {
- background(0);
- }