How do you change from windowed to fullscreen back to windowed

I am just unable to fix this problem i tried doing this with a simple boolean called screen to control what frame.setUndecorated is and than use frame.setSize to do the rest.

Problems!

For some reason openGl stops working so nothing will show once you go full screen plus It wont take any input after it goes into full screen to.

import processing.opengl.*;// allows fullscreen and more
import java.awt.Dimension; // to set  to frame allows limits 
Dimension minimumSize = new Dimension(830, 650); //Change values for limit
//Start up vars 
int stage=2;
PImage  glogo;
color blue=#333333;
//everything else i need

void setup() {
 // glogo=loadImage("cooltext1790730691.png");// game logo
  size(830, 650, OPENGL);
  frame.setTitle("test ");
  // app icon
  frame.setResizable(true);
  frame.setMinimumSize(minimumSize);
}



void draw() {
  if (mousePressed) {
    exit();
  }
  //image(intrologo, 0, 0, width, height);

  main_menu();
}



int window = 1;

void keyPressed() {


  if (key=='f') {
    if (window==1) {

      // to make a frame not displayable, you can
      // use frame.removeNotify()
      frame.removeNotify();

      frame.setUndecorated(true);

      // addNotify, here i am not sure if you have 
      // to add notify again.  
      frame.addNotify();
      super.init();
      frame.setLocation(0, 0);
      frame.setSize(830, 650);

      window=2;

    } else {

      // to make a frame not displayable, you can
      // use frame.removeNotify()
      frame.removeNotify();
      frame.setUndecorated(false);
      // addNotify, here i am not sure if you have 
      // to add notify again.  
      frame.addNotify();
      super.init();
      frame.setSize(minimumSize);
      window=1;
    }
  }
}









//game main menu
void main_menu() {
  int bc=150;//control where the menu is on the x axis and size
  background(0,255,0);
 // imageMode(CENTER);
 // image(glogo, width/2, 40);// game logo
 // imageMode(CORNER);
  stroke(blue);
  strokeWeight(6);
  //fill(#440044);
  rect(width/2-bc*2+bc-bc/2-0, height-bc-0, bc, bc, 5);//most on the right
  rect(width/2-bc/2, height-bc-0, bc, bc, 0);// center one change 0 to 4 in strokeweight
  rect(width/2+bc/2+0, height-bc-0, bc, bc, 5);//most on the right
}
Sign In or Register to comment.