How to remove window elements of a processing sketch?

Viewed 96

I'm wondering if it's possible to do something in processing java (or native java idk much about it though) where you can get rid of the windows gui elements of the window (I'm using windows 7). I want it to be able to look like when you boot up a program like eclipse or visual studio and it has like a rectangle in the middle of the screen, but you can't x out of the program or minimize it, etc. is that possible even or would I have to use another java library? Thanks.

1 Answers

Yes, you can. I had no idea, but you totally can! There's some class juggling involved, though, but it's all fairly simple.

Here's a code snippet for you to try and tinker with the principle:

import java.awt.Frame;
import processing.awt.PSurfaceAWT;
import processing.awt.PSurfaceAWT.SmoothCanvas;

void setup() {
  size(200, 200);
}

PSurface initSurface() {
  PSurface pSurface = super.initSurface();
  PSurfaceAWT awtSurface = (PSurfaceAWT) surface;
  SmoothCanvas smoothCanvas = (SmoothCanvas) awtSurface.getNative();
  Frame frame = smoothCanvas.getFrame();
  frame.setUndecorated(true);
  return pSurface;
}

void draw() {
  background(0);
  ellipse(mouseX, mouseY, 20, 20);
}

Have fun!

Related