No, I’m not talking about Christmas ornaments. I just came up with a quick hack to turn off the window frame from inside Processing. See this thread on the Processing forums to know why this is useful.

When running in the IDE the sketch runs as an applet, so it can’t use the “–present” command line switches available to applications because init() is called instead of main(). My hack simply overrides the default init(), sets the frame to be undecorated and then calls the regular PApplet.init().

Update: Setting the location of the window needs to happen in setup(), not init().

import processing.opengl.*;

void setup(){
  size(400,400,OPENGL);
  background(0);
  frame.setLocation(0,0); // needs to be in setup(), not init()
}

void draw(){
  stroke(255);
  line(0,0,200,200);
}  

public void init() {
  frame.setUndecorated(true); // works.

  // call PApplet.init() to take care of business
  super.init();
}

There are 4 comments to "Code: frame.setUndecorated(true);". You may leave your own comment.
1. Kyle, January 11th, 2007 at 09:49

main() is called after init(), which will reset any changes to the frame bounds. Instead, try moving frame.setLocation(0,0); into setup().

2. marius watz, January 16th, 2007 at 17:40

Thanks, Kyle, I’ve updated the code accordingly.

3. douglas edric stanley, March 3rd, 2007 at 02:21

Ah, very handy that. Thanx.

4. sergio, June 4th, 2007 at 04:20

Tried this in Eclipse, but to no result…
Unfortunately the applet won’t even initalize…
:-

Comment on this entry

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>