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() {
size(480, 320);
cp5 = new ControlP5(this);

mybutton = cp5.addButton(“Press”)
.setPosition(16, 20)
.setSize(168, 40)
.setLabel(“Select CSV file”)

void draw() {

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.