Changing the Icon of a G4P Window

edited March 2017 in Library Questions

@quark Quick question, how do you change the icon of a secondary window created using G4P?

Answers

  • Answer ✓

    There is nothing built into G4P that would allow you to do that for you.

    You would need to access the underlying window container object to have a chance of changing the icon.

    If you are using Processing V2 then all windows are created using JFrame no matter which renderer (JAVA2D, P2D or P3D) you use. In V3 that is only true for JAVA2D. The renderers P2D and P3D use the com.jogamp.newt.opengl.GLWindow class.

    So in Processing 3 and you have created a GWindow (secondary window) called window you can get the window's container object with

    JAVA2D (default)

    import javax.swing.JFrame;
      JFrame frame = (JFrame) ((processing.awt.PSurfaceAWT.SmoothCanvas) window.getSurface().getNative()).getFrame();
    

    P2D/P3D

    import com.jogamp.newt.opengl.GLWindow;
    GLWindow winGL = (GLWindow) window.getSurface().getNative();
    

    The next stage is to do some googling to find out how to use these to change the icon. I let you try that.

    If you think that this is a useful feature to include with G4P you can add a ticket here but it will be some time before I can do anything about it.

  • Thanks! Helped a lot.

Sign In or Register to comment.