Allow User to Resize the Window

Hello All,

I’m creating a program and I would like the user to be able to resize the screen at their convenience. I understand the basics of how to do this with objects and their positioning on the screen but I’m a little unclear how I can make the program itself have a customizable screen size.

I know about the settings() function, but is there a way to use that to give the user the ability to resize the screen while using a program?

Thank you all as always for the help.

Hey I think the function you are looking for is this:

surface.setResizable(true);

I have already make a little example :smile:

//previous Width/Height
float pWidth, pHeight;

void setup() {
  size(600, 600);
  surface.setResizable(true);
}
void draw() {
  background(0);
  updateWindowResized();
}
void updateWindowResized() {
  if (width != pWidth || height != pHeight) {
    pWidth = width;
    pHeight = height;
    windowResized();
  }
}
//called when the window was resized 
void windowResized() {
  println("Window resized");
}
2 Likes

This looks great, thank you very much for the help!

1 Like