I see, something like the following. But you said it stopped working in your original demo.
int counter = 0;
void setup() {
size(400, 400);
surface.setResizable(true);
}
void windowResized(){
println("window resized :", counter);
counter++;
}
void draw(){
background(0);
fill(255);
rect(0,0,width,height);
}