Is setUndecorated() possible?

I have 2 windows that I’m creating with the frames example of the controlP5 library. One works as the control window for sliders etc and the other the main sketch window where the artwork gets displayed.

I have 2 monitors. Using fullScreen(2) runs the main sketch window as fullscreen.
However, the control window is much smaller say size(400,800);

I don’t want the title bar and close/minimize buttons at the top.

Has setUndecorated() been completely removed in processing 3?
If so how may I achieve this.

I don’t want to make this control Window full screen. I wish it to remain at size(400,800).

Would really appreciate if someone could point me in the right direction as have been struggling for a while on this. Thanks!

2 Likes

@GoToLoop Can you please post explanations when you post links?

You can get to the old frame variable and the setUndecorated() function, but you have to go through the surface variable and it depends on which renderer you’re using. Here’s an example for the default renderer:

import java.awt.Frame;
import processing.awt.PSurfaceAWT;
import processing.awt.PSurfaceAWT.SmoothCanvas;
 
void setup() {
  size(200, 200);
}
 
PSurface initSurface() {
  PSurface pSurface = super.initSurface();
  PSurfaceAWT awtSurface = (PSurfaceAWT) surface;
  SmoothCanvas smoothCanvas = (SmoothCanvas) awtSurface.getNative();
  Frame frame = smoothCanvas.getFrame();
  frame.setUndecorated(true);
  return pSurface;
}
 
void draw() {
  background(0);
  ellipse(mouseX, mouseY, 20, 20);
}
2 Likes

Cool Thanks Kevin. Let me try this out.

Issue was surface.setResizable(true); was working and ``surface.setunDecorated(true); doesn’t exist

Right, surface doesn’t have a setUndecorated() function, presumably because not every renderer supports it.

There are other approaches in the link posted by GoToLoop. Here is one that’s probably better than the one I posted above:

void settings() {
    fullScreen();
}
void setup() {
    surface.setSize(500,500);
}
 
void draw() {
  background(0);
  ellipse(mouseX, mouseY, 20, 20);
}
3 Likes

Perfect!! It worked. So basically the fullScreen() removes the ‘frame decoration’ and setSize() and setLocation(); when used together can help you set the layout. Thanks Kevin… your example helped me understand this!

@GoToLoop Thanks! Am going through the old forum links as well. However, this one does the trick for immediate gratification :slight_smile:

1 Like

That’s a terrible idea if you want something that works cross-renderer and cross-platform - don’t assume that fullScreen just makes the window undecorated.

Yep, like I mentioned a few times: all of this depends on your renderer.

If you have a better solution I’d be curious to see it.

No, I agree with you, and your first answer - overriding initSurface() - is the way I do this. Depending on the renderer and the OS, fullScreen() can set flags on the window that you don’t want and can cause problems. The slightly longer-winded way you posted first is a safer bet. I only use the OpenGL renderers in PraxisLIVE. Interesting these return the window and not the canvas from getNative() so I override initSurface like (where wHints is my own config object) -

protected PSurface initSurface() {
    PSurface s = super.initSurface();
    s.setTitle(wHints.getTitle());
    GLWindow window = (GLWindow) surface.getNative();
    window.setAlwaysOnTop(wHints.isAlwaysOnTop());
    window.setUndecorated(wHints.isUndecorated());
    return s;
}
2 Likes