If you do not want to use windowed mode, just do not pass an argument:
PApplet.main(new String[] {"MyGame"});
If you want to switch from current mode to window mode, you will need to manually handle AFAIK. PApplet extends the java Applet class and uses Frame to add content to. Here is a quick hack:
import processing.core.PApplet; public class MyGame extends PApplet { public void setup(){ size(400,400); background(255); smooth(); stroke(0,32); } public void draw(){ fill(255,1); rect(0,0,width,height); translate(width/2,height/2); rotate(frameCount * .1f); line(0,0,width/3,0); } public void keyPressed(){ if(key == 'f') exitFullscreen(); } private void exitFullscreen() { frame.setBounds(0,0,width,height); setBounds((screenWidth - width) / 2,(screenHeight - height) / 2,width, height); frame.setLocation((screenWidth - width) / 2,(screenHeight - height) / 2); setLocation((screenWidth - width) / 2,(screenHeight - height) / 2); } public static void main(String args[]) { PApplet.main(new String[] { "--present", "MyGame" }); } }
Feel free to bother with the exitFullscreen () method to get the setting you need.
source share