Button automatically clicked once at the beginning of the program

The following is part of the testing code I’m working on:
I was trying to implement the button, and when it is clicked, it will print out the message “Button pressed”. I ran the program by clicking the run button on the top left corner of the Processing IDE. However, the console showed me the “Button clicked” message soon after the program begins, even when I did not click on the button I created. Does anyone know what had happened? Thanks to whoever my help
import processing.serial.;
import java.io.
;
import java.util.;
import controlP5.
;

ControlP5 cp5;
Button mybutton;

void setup() {
clear();
size(480, 320);
noStroke();
cp5 = new ControlP5(this);

mybutton = cp5.addButton(“Press”)
.setValue(0)
.setPosition(16, 20)
.setSize(168, 40)
.setLabel(“Select CSV file”)
.activateBy(ControlP5.RELEASE);
;
}

void draw() {
background(128);
}

public void Press() {
println(“Button pressed”);

}

that i see already,

sorry, no idea how to avoid it.

This seems to be part of the cp5 library.
Probably the easiest solution, since the event gets triggered immediately:

void press() {
  if (frameCount > 0) {
    // Do some stuff here.
  }
}
1 Like

Ok. Thank you.
:star_struck::star_struck: