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”);
}