# 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:** 5

<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:57am UTC](https://discourse.processing.org/t/dynamically-setting-the-window-as-undecorated/33327/5 "2021-12-19T10:57:00Z")

</div>

Moment of truth.  
Here is the last revision, I hope! 😂

**I’m sad to say this, but this only supports the** `P2D` **and** `P3D` **renderers!**  
Pretty sure most people will be using `GPU`-based rendering anyway, amIrite?

Also, there is bad luck involved…  
In short, this could change with newer versions of Processing, …and:

> [@Getting A Sketch's Window's Position](https://discourse.processing.org/t/getting-a-sketchs-windows-position/31772/7):
>
> Just adding a note for people deciding on whether to go the getNative() route: not only is it a renderer specific Object – a whatever-the-renderer-gives-us – but it could be subject to change. This is whimsically expressed in the Processing API documentation… from [PSurface.getNative](http://processing.github.io/processing-javadocs/core/processing/core/PSurface.html#getNative--) : Get the native window object associated with this drawing surface. For Java2D, this will be an AWT Frame object. For OpenGL, the window. The data returned here is subject to the whims of the renderer, and using …

**The code, yay!:**

```java
import com.jogamp.newt.opengl.GLWindow;
// [https://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/newt/opengl/GLWindow.html];

GLWindow window;

void setup() {
  size(640, 480, P3D);
  registerMethod("post", this); // Never forget the "this dot", and also this!!11!

  sphereDetail(8);
  surface.setResizable(true);
  surface.setTitle("haha press f11");
  window = (GLWindow) surface.getNative();
}

void draw() {
  background(0);

  stroke(255);
  strokeWeight(8);
  line(
    map(window.getX(), 0, displayWidth, 0, width*1.75), 0, 
    map(window.getX(), 0, displayWidth, 0, width*1.75), 
    map(window.getY(), 0, displayHeight, 0, height*2.5)
    );

  if (mousePressed) stroke(255f, 0, 0);
  strokeWeight(1f);
  noFill();
  lights();
  translate(mouseX, mouseY);
  rotateX(millis()*.001f);
  rotateZ(millis()*.001f);
  sphere(50f);
}

boolean fs;
void keyPressed() {
  if (keyCode == 107) {
    fs = !fs;
    surface.setSize(displayWidth, displayHeight);
    if (!fs) surface.setSize(640, 480);
  }
}

void post() {
  if (fs)
    if (!window.isUndecorated()) {
      window.setVisible(false);
      try {
        window.setUndecorated(true);
      }
      catch(Exception e) {
      }
      window.setVisible(true);
      while (!window.isUndecorated());
    } else surface.setLocation(0, 0);
  else if (window.isUndecorated())
  try {
    window.setVisible(false);
    window.setUndecorated(false);
    window.setVisible(true);
  } 
  catch(Exception e) {
  }
}

```

---

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