How to disable window maximization

Hello,
Every time I create a new processing sketch it adds a maximize screen button to the running window. I know its possible to just use

void draw(){
  surface.setSize(500,500);
}

to keep the window at a constant size, but I was wondering if there were any solutions that could remove the button entirely.
Thanks.

https://forum.processing.org/two/search?Search=setUndecorated

1 Like

Hi,

i think frame.setUndecorated(true); works for processing 1.5.1 only (at least i didn t succed to apply it to surface)

a workaround (at least on mac) is:

int x = 0;

void setup() {
  fullScreen();
  surface.setResizable(true);
  surface.setSize(500,500);
  surface.setLocation(displayWidth/2-250, displayHeight/2-250);
  background(0);
  noStroke();
  fill(102);
}

void draw() {
  fill(color(random(255)));
  rect(x%500, height*0.2, 1, height*0.6); 
  x = x + 2;
}

but it s kind of weird, forcing fullscreen to avoid decoration then size down, and as it is not what those function was developped for, i can 't say if it works on other computers than mine…

1 Like

Hey, I don’t know if it’s the best solution, but it seems to work:

void setup() {
  //for the background color
  colorMode(HSB, 10000, 10000, 10000);
  //Fullscreen "disables" the button
  fullScreen(P2D);
  //sets the size 
  surface.setSize(600, 600);
  //And so that the window is not on the top left, we put it in the middle
  surface.setLocation(displayWidth/2-width/2, displayHeight/2-height/2);
}
void draw() {
  background(millis()%10000, 10000, 10000);
}

I hope I could help you :slight_smile:

Perhaps surface.setResizable(false); will handle the original question?!

Be careful using fullScreen - with different OS and different renderers it sets up different metadata on the window that might cause issues.

There are renderer specific ways to set undecorated if you get the native window and cast. eg. with P2D and P3D

import com.jogamp.newt.opengl.GLWindow;
...
GLWindow window = (GLWindow) surface.getNative();
window.setAlwaysOnTop(true);
window.setUndecorated(true);

hi, neilcsmith

thanks for this surface.getnative(), i didn t know it

i m agree fullscreen is not best way
but on macos, window.setUndecorated(true); make it crash, sadly