Processing 3: init() disappearance

edited October 2015 in Questions about Code

I used to do some stuff in init() to create an undecorated (non-full-screen), always on top window at a specific position like this:

public void init() { frame.setAlwaysOnTop(true); frame.removeNotify(); frame.setUndecorated(true); frame.setLocation(0, 0); super.init(); }

Since init() has disappeared (and frame stuff is deprecated), how is this still possible. I browsed the PApplet and the PSurface code, but I'm not getting it... Only found solutions for full-screen...

Regards, Peter

Answers

  • I believe you might be looking for the settings() function: https://www.processing.org/reference/settings_.html

    And the surface variable.

  • Kevin,

    This seems to be something similar (and thanks for pointing this out), but the disappearance of the frame variable (and the surface variable not being the same) does not allow me to do the same as before: Processing output window NON-fullscreen, undecorated, and at a specific location. (Or maybe I just don't get it...)

    Thanks anyway, Peter

  • Well, Processing 3 is very different from Processing 2, so expect your code to be different.

    You can still get to the Frame if you make assumptions about what type of Surface you're using. This is hackish, but it works for me:

    import processing.awt.PSurfaceAWT;
    
    void setup(){
        PSurfaceAWT awtSurface = (PSurfaceAWT)surface;
        PSurfaceAWT.SmoothCanvas smoothCanvas = (PSurfaceAWT.SmoothCanvas)awtSurface.getNative();
        smoothCanvas.getFrame().setAlwaysOnTop(true);
        smoothCanvas.getFrame().removeNotify();
        smoothCanvas.getFrame().setUndecorated(true);
        smoothCanvas.getFrame().setLocation(0, 0);
        smoothCanvas.getFrame().addNotify();
    }
    
    void draw(){
      background(0);
      ellipse(50, 50, 10, 10);
    }
    

    The good news is that you can still get to all of this stuff, so it's at least possible for the Processing developers to make it more accessible. You might consider raising an issue on Processing's GitHub page requesting this feature. Feel free to point to this post as an example.

    In the meantime, this code works on my system, but I wouldn't rely on it too heavily, since things could change again.

  • Kevin,

    Thanks a lot! this helps. I believe I already read some discussion (by the developers) about these 'window' issues (setTitle, setResizable, setLocation, etc..) but I'm not sure it has already been addressed (although the discussion WAS in the 'alpha' phase... ([https://github.com/processing/processing/issues/3388]). It would be nice if the issue is solved and we do not have to rely on 'hacking' for this :-)

    Regards,

    Peter

Sign In or Register to comment.