How to access smoothCanvas.getFrame().setUndecorated in Python Mode

edited August 2017 in Python Mode

I would like to use this Code I found on the forum, but in Python mode. I just can't figure out how to wirte this in Python:

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(200, 200);
    smoothCanvas.getFrame().addNotify();
}

I would be thankfull for any help!

Answers

  • edited August 2017
    """
     Surface (v2.0.1)
     GoToLoop (2017-Aug-05)
    
     Forum.Processing.org/two/discussion/23716/
     how-to-access-smoothcanvas-getframe-setundecorated-
     in-python-mode#Item_1
    """
    
    size(800, 600, JAVA2D)
    smooth(3)
    noLoop()
    
    colorMode(RGB)
    blendMode(REPLACE)
    
    surface = this.surface
    
    surface.setSize(width >> 1, height >> 1)
    surface.frameRate = 7.5
    
    background(int(random(PImage.ALPHA_MASK)))
    
    surface.alwaysOnTop = True
    surface.resizable = True
    surface.visible = True
    
    surface.cursor = CROSS
    surface.showCursor()
    
    x = displayWidth - width >> 1
    y = displayHeight - height >> 1
    surface.setLocation(x, y)
    
  • thank you for your answer, but the Code doesn't seem to give me access to setUndecorated, or turn of the window frame in any other way.

  • edited August 2017 Answer ✓
    """
     Surface (v3.1.1)
     GoToLoop (2017-Aug-05)
    
     Forum.Processing.org/two/discussion/23716/
     how-to-access-smoothcanvas-getframe-setundecorated-
     in-python-mode#Item_3
    """
    
    def setup():
        size(800, 600, JAVA2D)
        smooth(3)
        noLoop()
    
        colorMode(RGB)
        blendMode(REPLACE)
    
        globalSurfaceJFrame()
        configSurface()
        toggleWinDecor()
    
    
    def draw(): background(int(random(PImage.ALPHA_MASK)))
    
    def keyPressed(): redraw()
    
    def mousePressed(): keyPressed()
    
    
    def globalSurfaceJFrame():
        global surface, jframe
        surface = this.surface
        jframe = surface.native.frame
    
    
    def setWinDecor(activate=False):
        jframe.removeNotify()
        jframe.undecorated = not activate
        jframe.addNotify()
    
    
    #Toggling CRASHES after setup()!!!
    def toggleWinDecor(): setWinDecor(jframe.isUndecorated())
    
    def configSurface():
        surface.setSize(width >> 1, height >> 1)
        surface.frameRate = 7.5
    
        surface.alwaysOnTop = True
        surface.resizable = True
        surface.visible = True
    
        surface.cursor = CROSS
        surface.showCursor()
    
        x = displayWidth - width >> 1
        y = displayHeight - height >> 1
        surface.setLocation(x, y)
    
  • thank you very much! I noticed you post alot of answers on many questions I found today. Can you tell me what sources you use to figure this out? I couldn't find anything in the Reference.

  • edited August 2017

    thank you. Do you know of a solution for openGL(P2D / P3D) or only for the JAVA2D renderer?

  • Answer ✓

    The other renderers aren't based on JFrame. :-\"

Sign In or Register to comment.