Thank you for your answer. I installed the G4P library via the Processing IDE and made the following script using the examples provided in the IDE, to get a textfield:
import g4p_controls.*;
GTextField txf1;
public void setup() {
size(500, 300);
txf1 = new GTextField(this, 10, 10, 200, 20);
txf1.setPromptText("Text field 1");
txf1.setText("test1"); // works
}
public void draw() {
background(200, 128, 200);
if (keyPressed && key == ENTER){
println(txf1.getText());
txf1.setText("test2"); // gives nullpointerexception
}
}
However, when I try to set a new text in the textfield, I get a nullpointer exception. The setText() function does work as expected in the setup, but not in the draw. Does anyone know how I can solve this problem?