# Dynamically Setting the Window as Undecorated

**URL:** <https://discourse.processing.org/t/dynamically-setting-the-window-as-undecorated/33327>\
**Category:** Coding Questions\
**Created:** [November 5, 2021, 11:24am UTC](https://discourse.processing.org/t/dynamically-setting-the-window-as-undecorated/33327 "2021-11-05T11:24:42Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Brahvim](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/brahvim/32/14756_2.png) [@Brahvim](https://discourse.processing.org/u/Brahvim)\
**Post date:** [December 19, 2021, 10:21am UTC](https://discourse.processing.org/t/dynamically-setting-the-window-as-undecorated/33327/3 "2021-12-19T10:21:01Z")

</div>

- What even **IS** this/?/1!?1?  
So you know how video games (like Minecraft!!1!) resize the window to ‘fullscreen’ when you press `F11`? This does that. **Setting the window to “undecorated” means to remove the title bar, the window maximize, window minimize, and window close buttons.**

- How did you do it, `("o_O))`?  
Right: here is an explanation as to how this works:  
Basically, the `window.setUndecorated()` method runs a new thread. If you continue to use `draw()`, you are rendering graphics to the screen, which disrupts, or `interrupts` that thread.  
To avoid that, **I simply put a `while` loop to wait till the thread is done.**  
The `if` exists to check if the window was already set to undecorated, and if it needs to be done again, since **it takes a bit of time to set the window as undecorated**!

- Why do I set the window to invisible and then visible?  
Because for some reason, it resizes it perfectly to fit the screen, and also makes the taskbar disappear. It is needed even though there is a `surface.setLocation(0, 0);`

- Why am I using a method called ‘`post()`’ and what is it?!  
Processing “handles” the `draw()` function inside a function called `handleDraw()`, which runs every frame. However, to ensure that the `draw()` function is ‘safe’ to use (so you didn’t change things and cause random errors all the time), the Processing development team made sure that you couldn’t access them. Problem: **libraries need this functionality** , and so do we! So they allowed it to be extended and made two more methods, called `pre()` and `post()`, which are called **before** and **after** `draw()` is executed, respectively.

- Why so many `if`s?!  
If you’ve ran this code, you know how long it takes to do the task! The `if`s ensure that the task isn’t done every single frame - it’s an optimization. But **the solution as a whole isn’t as optimized.**  
** ~~_I’ll post the ‘optimized’ version of the code soon!_~~  
Check the solution answer [here](https://discourse.processing.org/t/dynamically-setting-the-window-as-undecorated/33327/5)**, ":D!

- What’s this “`window`” object?!  
This is a way to dig into Processing’s workings and do some of this stuff. I myself came to know about it from here, **months** ago: [Get location of a PApplet window - #10 by micycle](https://discourse.processing.org/t/get-location-of-a-papplet-window/28039/10)  
**To know what it contains** , check the solution answer [here](https://discourse.processing.org/t/dynamically-setting-the-window-as-undecorated/33327/5)

---

_[View the full topic](https://discourse.processing.org/t/dynamically-setting-the-window-as-undecorated/33327)._
