[ControlP5] change button text color

Hi everyone!

I am trying to design buttons with different colors but i don’t know how to change the color of name button inside it.Normally the color is white and every sketch i see online uses this color.Can i add something to the code for doing this thing?

This is the classic code i wrote:

import controlP5.*; //import ControlP5 library
import processing.serial.*;

Serial port;

ControlP5 cp5; //create ControlP5 object
PFont font;

void setup(){ //same as arduino program

  size(1366, 768);    //window size, (width, height)
  
  printArray(Serial.list());   //prints all available serial ports
  
  //port = new Serial(this, "COM3", 9600);  //i have connected arduino to com3, it would be different in linux and mac os
  
  //lets add button to empty window
  
  cp5 = new ControlP5(this);
  font = createFont("arial", 20);    // custom fonts for buttons and title
  
  cp5.addButton("rosso")     //"red" is the name of button
    .setPosition(100, 50)  //x and y coordinates of upper left corner of button
    .setSize(100, 70)      //(width, height)
    .setFont(font)
    .setColorBackground(color(255, 0, 0))
  ;

Thanks for your help

Try:
.setColorCaptionLabel(color(0,0,0))

2 Likes

Welcome to the forum.

I have moved this discussion to the ‘Libraries’ section because the question is about using the ControlP5 library not about using Arduino.

2 Likes

I tried using this and it works.Thank you so much.Where can i find these instruction?Are they in the library o in processing?

Look in Examples/Contributed Libraries/ControlP5/ControlP5button and scroll all the way to the bottom.

1 Like

Perfect,thank you for your help