A possible bug of Processing (?) - cannot resize window by Java2D, but ok by P2D and P3D

My project allows the users to resize windows. It works fine before in my old PC with Win10 and Processing 4.1.1. Now I change my PC to a new one with Win 11, and with graphics card NVIDIA RTX A4000. I find that I cannot resize the window anymore. Every time I resize it, the window halted and the extra area in window becomes black color. The program even don’t run the draw() function. I am now using Processing 4.3. My JDK in this new PC was JDK8 and then I upgraded it to JDK11 and JDK21. I also update the driver of my graphic card to the latest. The problem still exists. It exists even I just used a very simple program (from Processing web site) to test. The code is here:

void setup() {
size(200, 200);
surface.setTitle("Hello World!");
surface.setLocation(100, 100);
void draw() {
line(0, 0, width, height);
line(width, 0, 0, height);

However, if I use P2D or P3D as the rendener in the above example, the window can resize and the problem does not exist anymore. Unfortunately I cannot change my project to use P2D or P3D because it involves too many changes. Can anyone tell me how to solve this issue? Or this is a bug in Processing?

Just add a bit more information. This is not the first time I encounter this problem. The problem may not simply related with Win11. I encountered this problem in PC of Win10 before but it just rarely happened on one or two PC, not commonly happened.