Disable maximize button?

I want a fixed window size, I don't want the maximize button to make the window full screen.

setResizable does nothing. Calling size() every frame breaks sketch.

Answers

  • edited April 2018

    Thanks kfrajer, but that only seems to work with the default renderer, not P2D or P3D.

    import processing.awt.PSurfaceAWT.SmoothCanvas;
    import com.sun.awt.AWTUtilities;
    import javax.swing.JFrame;
    import javax.swing.JRootPane;
    
    JFrame jframe;
    
    static final JFrame getJFrame(final PSurface surf) {
      return (JFrame) ((SmoothCanvas) surf.getNative()).getFrame();
    }
    
    
    
    void setup() {
      size(500, 500,P3D);
      //size(500, 500);
      jframe = getJFrame(getSurface());
    }
    
    int i = 0;
    void draw(){
      background(i);
      i++;
      if (i>255) i=0;
    }
    

    That works but only with the default renderer.

    It errors,

    No library found for processing.awt.PSurfaceAWT

    No library found for com.sun.aw

    Also I couldn't any hooks for the window being resized, like onResize() or something similar. Is there an index of all the built in processing hooks (like void mouseMoved()) i couldn't find such a list in the reference.

  • Not tested, but try:

    surface.setResizable(false);

    after calling size. Or try GoTo's first post here: https://forum.processing.org/two/discussion/3013/are-undecorated-frames-dead-with-processing-2-x

    Is there an index of all the built in processing hooks

    The reference only documents the basic functions that can be accessed by the common users of the Processing library, keeping in mind Processing is directed to a public with less experience in Programming with the concept to engage them into programming. It is my understanding they don't intend to document all the built-in functionalities. These other functions are found mostly by checking previous posts or browsing the source code available in GitHub.

    Kf

  • edited April 2018

    with size() being called in settings(),

    surface.setResizable(false); does nothing in setup(); It does nullpointerexception in settings() after size();

    frame.setResizable(false) also doesn't work.

    void setup() {
      size(400, 300, removeFrameBorder());
    
      frameRate(60);
      smooth(8);
      stroke(#00FFFF);
      strokeWeight(1.5);
      textSize(32);
    }
    
    void draw() {
      background(0300);
    
      fill(#FF0000);
      text(frameCount, width - 100, 40);
    
      fill(#0000FF);
      translate(frameCount % width, height >> 1);
      sphere(96);
    }
    
    String removeFrameBorder() {
      if (!isGL()) {
        frame.removeNotify();
        frame.setUndecorated(true);
        frame.addNotify();
      }
    
      return P3D;
    }
    

    this code from your link doesn't work because isGL doesn't work in processing3, also size needs to be in settings()

  • edited April 2018

    Still really need a way to keep from changing window size for P3D renderer..

    My hack was to check if height or width have changed at the start of draw() and if so, change the size back.

Sign In or Register to comment.