# GWindow 'g4p' / Draws incorrectly. (Windows 'new window' problem)

**URL:** <https://discourse.processing.org/t/gwindow-g4p-draws-incorrectly-windows-new-window-problem/45942>\
**Category:** Libraries\
**Created:** [March 9, 2025, 11:29pm UTC](https://discourse.processing.org/t/gwindow-g4p-draws-incorrectly-windows-new-window-problem/45942 "2025-03-09T23:29:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [March 9, 2025, 11:29pm UTC](https://discourse.processing.org/t/gwindow-g4p-draws-incorrectly-windows-new-window-problem/45942/1 "2025-03-09T23:29:24Z")

</div>

GWindow ‘g4p’ / Draws incorrectly. (Windows ‘new window’ problem)

 ![fig1](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/c/a/caffbfe1bc5feac68b71c9b510172fd97566ae48.jpeg)  
 ![fig2](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/8/4/842bbd4c838bd203c6f0a1530faccb5ba5ce7216.jpeg)

1. Please check 2 images.

- If it is drawn correctly, if it is drawn incorrectly

1. Draw stops after 1 operation with ‘noLoop’.

- Is there a way to increase the probability (accuracy) of drawing correctly?

```Java
import g4p_controls.*;
ArrayList<GWindow> windowsList;
GWindow window_cycle_list;
void WIN_SETUP_cyclist(int w_x, int w_y){

  //------------------------------------------------------//
  windowsList = G4P.getOpenWindowsAsList(windowsList);
  if(windowsList.contains(window_cycle_list)){ window_cycle_list.close(); return;}
  //------------------------------------------------------//

  //------------------------------------------------------//
  window_cycle_list = GWindow.getWindow(this, "Cycle List", w_x, w_y, 600, 300, JAVA2D);
  window_cycle_list.setActionOnClose(window_cycle_list.CLOSE_WINDOW);
  //------------------------------------------------------//
  
  //------------------------------------------------------//
  window_cycle_list.setAlwaysOnTop(true); window_cycle_list.addDrawHandler(this, "windowLIST"); window_cycle_list.addMouseHandler(this, "windowMouse_LIST");
  window_cycle_list.textFont(myFont_N); window_cycle_list.imageMode(CENTER); window_cycle_list.textAlign(CENTER); window_cycle_list.frameRate(1);
  window_cycle_list.background(255);
  window_cycle_list.rectMode(CENTER);
  //------------------------------------------------------//

}
public void windowLIST(PApplet appc, GWinData data) {
  
  int g_x=0,g_y=0,g_w=0,g_h=0,g_w2=0,g_h2=0;
  int g_c=350; 
  int g_c_y=250; 
  int g_x1=110, g_x2=330, g_x3=515;
  appc.background(255); appc.textAlign(CENTER,CENTER); 
  
  
  //----------------------------------------------------------------------------//  
  //----------------------------------------------------------------------------// 
   g_y=40; g_h2=18;    
   boolean i_n = true; appc.noStroke();
   for (int i = 0; i < 16; i++){ 
     if(i==0){ appc.fill(0,112,192); } 
     else{
       if(i_n){i_n=false; appc.fill(255); }
          else{i_n=true; appc.fill(218,227,243); }
     }
     appc.rect(300,g_y+i*g_h2,600,g_h2);
   } 
  appc.stroke(255); appc.strokeWeight(2);
  appc.line(220,0,220,600); appc.line(440,0,440,600);
  //----------------------------------------------------------------------------//  
  //----------------------------------------------------------------------------//  
  
   
  //----------------------------------------------------------------------------//  
  //----------------------------------------------------------------------------//  
   g_y=36;appc.textSize(16);
   appc.text("Start Date/Time",g_x1,g_y); appc.text("End Date/Time",g_x2,g_y); appc.text("Log",g_x3,g_y);   
   
   appc.fill(30); g_y=55; appc.textSize(12);
   for (int i = 0; i < 15; i++){     
     appc.text(HISTORY_CYCLE[i][0],g_x1,g_y+round(g_h2*(i)));  
     appc.text(HISTORY_CYCLE[i][1],g_x2,g_y+round(g_h2*(i)));  
     appc.text(HISTORY_CYCLE[i][2],g_x3,g_y+round(g_h2*(i))); 
   }      
  //----------------------------------------------------------------------------// 
  //----------------------------------------------------------------------------//  
  
  
  //----------------------------------------------------------------------------// 
    g_x=530; g_y=12; g_w=125; g_w2=135; g_h=26; 
    appc.fill(10);
    appc.rect(g_x,g_y,g_w,g_h,30);  
    appc.fill(255); appc.textSize(15); appc.textAlign(CENTER,CENTER);
    appc.text("EXIT",g_x,g_y-3);   
  //----------------------------------------------------------------------------// 
  

  appc.noLoop();
  return;
  
  
}

```

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [March 10, 2025, 6:55am UTC](https://discourse.processing.org/t/gwindow-g4p-draws-incorrectly-windows-new-window-problem/45942/2 "2025-03-10T06:55:46Z")

</div>

![fig3](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/8/4866e697736b5a37bfa23168d20bbcd054825aba.jpeg)

Why is this a problem?

I’m curious.

Is it a problem with the computer? Or is it a problem with the source configuration?

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [March 10, 2025, 3:33pm UTC](https://discourse.processing.org/t/gwindow-g4p-draws-incorrectly-windows-new-window-problem/45942/3 "2025-03-10T15:33:19Z")

</div>

> [@GWAK](#):
>
> Is it a problem with the computer?

That would be incredibly unlikely

> [@GWAK](#):
>
> is it a problem with the source configuration?

Depends what you mean by **source configuration**

> Is it a problem with G4P  
> I can’t see that being a possibility either since the methods you are using belong to Processing 😇

In the first image we see that the problem arises part way through drawing a row 👎 which suggests that something in your code either changes the text alignment or the text render position.

 ![Screenshot 2025-03-10 at 15.24.55](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/8/f/8faaddc2ddd56d793b8d10ed4354f8d780f0ecf8.png)

From the code snippets provided I can’t see where the problem arises 😒

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [March 10, 2025, 11:43pm UTC](https://discourse.processing.org/t/gwindow-g4p-draws-incorrectly-windows-new-window-problem/45942/4 "2025-03-10T23:43:44Z")

</div>

@quark  
Thank you for your reply.

Am I the only one experiencing this phenomenon?

The configuration is as follows.

1. 'Original window ’
2. ‘New window’: ‘G4P library’

(There is an example of this scenario.)

1. When a new window opens,
2. The text in the ‘original window’ shakes, or the text in the ‘new window’ shakes.
3. Even so, if you reduce ‘frameRate’, the frequency decreases.
4. The current source code only runs once due to ‘noLoop’. So I think that moment was captured.

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [March 11, 2025, 8:50am UTC](https://discourse.processing.org/t/gwindow-g4p-draws-incorrectly-windows-new-window-problem/45942/5 "2025-03-11T08:50:09Z")

</div>

> [@GWAK](#):
>
> The text in the ‘original window’ shakes, or the text in the ‘new window’ shakes

No one has reported a similar problem.

Each `GWindow` is effectively a _separate_ PApplet with its own main-event-thread so each thread must be responsible for rendering its _ **own display** _. Also if data is being shared between the windows this can cause problems.

> [@GWAK](#):
>
> The current source code only runs once due to ‘noLoop’. So I think that moment was captured.

I don’t think so because `noLoop` sets a flag to prevent the _ **next** _ call to draw, it doesn’t stop the draw method during its execution. So if all the text is being drawn in a single operation any call to `noLoop` would not affect the current frame.
