If it’s helpful, here is a shorter example program that demonstrates the same problem:
import g4p_controls.*;
public void setup() {
size(200, 200);
GButton button = new GButton(this, 75, 75, 100, 50, "Click me");
button.addEventHandler(this, "buttonClicked");
}
public void draw() {
fill(255, 0, 0);
rect(25, 25, 100, 100);
}
public void buttonClicked(GButton source, GEvent event) {
saveFrame("###-button.png");
}
void keyPressed() {
save("###-key.png");
}
When I run this, I see the button displayed on top of the red square:
But when I save a screenshot, the red square is on top: