# How to open window maximised?

**URL:** <https://discourse.processing.org/t/how-to-open-window-maximised/42450>\
**Category:** Coding Questions\
**Created:** [July 19, 2023, 7:51am UTC](https://discourse.processing.org/t/how-to-open-window-maximised/42450 "2023-07-19T07:51:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![turke1034](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/turke1034/32/16910_2.png) [@turke1034](https://discourse.processing.org/u/turke1034)\
**Post date:** [July 19, 2023, 7:51am UTC](https://discourse.processing.org/t/how-to-open-window-maximised/42450/1 "2023-07-19T07:51:19Z")

</div>

Hi, I want to know how to open the window maximised. Either it would open already maximised, or I could maximise it immediately after it opens. I have the following code from a stackoverflow answer:

```auto
com.jogamp.newt.opengl.GLWindow window = (com.jogamp.newt.opengl.GLWindow)(surface.getNative());
window.setResizable(true);
window.setMaximized(true, true);
//get window width and height without window decorations
println(window.getWidth(), window.getHeight());

```

However, this code crashes the program with this message:

> handleDraw() called before finishing

What happens is, the window pops up then immediately closes with the crash. However, removing 'window.setResizable(true);" actually makes the window resize after popping up, but it still crashes.

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [July 22, 2023, 2:34pm UTC](https://discourse.processing.org/t/how-to-open-window-maximised/42450/2 "2023-07-22T14:34:23Z")

</div>

Hi @turke1034,

simply call it this way. otherwise you will run into multithreading issue as shown above …

Hope that helps…

Cheers  
— mnse

```auto
void setup() {
  size(500, 500, P2D);
  java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
      final com.jogamp.newt.opengl.GLWindow window = (com.jogamp.newt.opengl.GLWindow)(surface.getNative());
      window.setResizable(true);
      window.setMaximized(true, true);
    }
  });
}
void draw() {
  background(0, 0, 255);
}

```

---

<div class="post-metadata">

**Author:** ![turke1034](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/turke1034/32/16910_2.png) [@turke1034](https://discourse.processing.org/u/turke1034)\
**Post date:** [July 22, 2023, 11:42pm UTC](https://discourse.processing.org/t/how-to-open-window-maximised/42450/3 "2023-07-22T23:42:49Z")

</div>

Hi mnse, this solves what was asked for in the question, thank you very much. But there is 1 more thing I would like to achieve which making it so the user can’t resize the window, because I am trying to simulate fullscreen, which is broken in P2D. I removed `window.setResizable(true);` however it is still resizable. I added `surface.setResizable(false);` after in setup() but its the same result.

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [July 23, 2023, 7:22am UTC](https://discourse.processing.org/t/how-to-open-window-maximised/42450/4 "2023-07-23T07:22:52Z")

</div>

Hi @turke1034,

Okay!? Never ran into issue while using `fullScreen(P2D)` !? What OS you are working on ?  
The `setResizable()` functionality depends a bit on OS behaviour, resp. underlying windowmanager.  
If you want to simulate `fullScreen(P2D)` you should use undecorated windows, so for this case I would do…

Hope that helps …

Cheers  
— mnse

```auto
void setup() {
  size(500, 500, P2D);
  java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
      final com.jogamp.newt.opengl.GLWindow window = (com.jogamp.newt.opengl.GLWindow)(surface.getNative());
      window.setUndecorated(true);
      window.setMaximized(true, true);
    }
  });
}

void draw() {
  background(sin(frameCount/100.)*128+128, 0, cos(frameCount/100.)*128+128);
}

```

---

<div class="post-metadata">

**Author:** ![turke1034](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/turke1034/32/16910_2.png) [@turke1034](https://discourse.processing.org/u/turke1034)\
**Post date:** [July 24, 2023, 5:19am UTC](https://discourse.processing.org/t/how-to-open-window-maximised/42450/5 "2023-07-24T05:19:54Z")

</div>

Hi mnse, I am using windows. According to github there is an issue that the windows magnification in settings impacts the behaviour of fullscreen, probably because processing’s method of making a fullscreen display doesn’t account for certain things.

Making the window undecorated is great thanks so much, its exactly the way fullscreen works. Its all I’ve changed for now, but I’ll report if I encounter anything else.
