Processing is responsible for calling the draw() method 60 times a second (default). Processing also provides methods to change the framerate, enable/disable looping and redraw the screen on demand (when not looping).
When the sketch is launched a pre-processor takes the users source code and wraps it into a class that extends the PApplet class (provided by Processing). So the user’s setup() and draw() methods override the ones in PApplet.
Java doesn’t have a native window resize event (at least it didn’t, don’t know about latest versions) letting the OS perform the actual resize, leaving the content to the app. Processing regularly checks the size of window and updates the width and height variables.
One thing you might try is to change the default JAVA2D renderer for P2D as they use different window classes
After 7 years I can be forgiven for forgetting my own posts LOL.
For others interested the 2016 discussion provided one answer based on code provided by GoToLoop and myself.
After a googling to find the 2016 post I found this discussion from 2018 where I show a simple safe way for your sketch to detect a change in the width or height
Hope these provide an insight into the window resize topic.
Think of it as when the window is resized that method is called. this allows u to be able to do anything after the window is resized with is what pre() is doing in this discussion.