thanks that works great.
just for the record here is the corrected code. it's a separate class that can just be called from the papplet like this:
Fullscreen.toggle(this);
note there are a few things also to be aware of:
1) smooth seems to get undone by any resizing of the frame, so i also call smooth() once a second from within draw() -- i dont' think this costs anything to call frequently since it's just setting a boolean, but someone correct me if i'm wrong. (nothing happened if i called `papplet.smooth();` from the toggle method, so easier to just override it centrally.)
2) mac os has about 21 pixels of chrome on the top of of the screen, so it's also helpful to compensate for that in setLocation and setSize. i haven't tested this on Windows, so not sure how it works there..
Code:import java.awt.Dimension;
import java.awt.Toolkit;
import processing.core.PApplet;
public class Fullscreen {
private static boolean FULL_SCREEN = false;
public static Dimension APP_SIZE = new Dimension(800, 600);
private static void setChrome(PApplet papplet, boolean full) {
papplet.frame.setUndecorated(full);
}
private static void setLocation(PApplet papplet, boolean full) {
papplet.frame.setLocation(0, 0);
}
private static void setSize(PApplet papplet, boolean full) {
if (full) {
papplet.frame.setSize(Toolkit.getDefaultToolkit().getScreenSize());
} else {
papplet.frame.setSize(APP_SIZE);
}
}
public static void toggle(PApplet papplet) {
FULL_SCREEN = !FULL_SCREEN;
papplet.frame.dispose();
papplet.frame.setResizable(!FULL_SCREEN);
setSize(papplet, FULL_SCREEN);
setChrome(papplet, FULL_SCREEN);
setLocation(papplet, FULL_SCREEN);
papplet.frame.setVisible(true);
}
}