@@ -49,14 +49,15 @@ public class PSurfaceAWT extends PSurfaceNone {
4949 GraphicsDevice displayDevice ;
5050
5151 // used for canvas to determine whether resizable or not
52- // boolean resizable; // default is false
52+ boolean resizable ; // default is false
5353
5454 // Internally, we know it's always a JFrame (not just a Frame)
5555// JFrame frame;
5656 // Trying Frame again with a11 to see if this avoids some Swing nastiness.
5757 // In the past, AWT Frames caused some problems on Windows and Linux,
5858 // but those may not be a problem for our reworked PSurfaceAWT class.
5959 JFrame frame ;
60+ boolean frameSetupComplete ;
6061
6162 // Note that x and y may not be zero, depending on the display configuration
6263 Rectangle screenRect ;
@@ -85,6 +86,8 @@ public PSurfaceAWT(PGraphics graphics) {
8586 //this.graphics = graphics;
8687 super (graphics );
8788
89+ this .resizable = false ; // Default is false, can be changed with surface.setResizable()
90+
8891 /*
8992 if (checkRetina()) {
9093// System.out.println("retina in use");
@@ -196,8 +199,7 @@ public Dimension getMinimumSize() {
196199
197200 @ Override
198201 public Dimension getMaximumSize () {
199- //return resizable ? super.getMaximumSize() : getPreferredSize();
200- return frame .isResizable () ? super .getMaximumSize () : getPreferredSize ();
202+ return resizable ? super .getMaximumSize () : getPreferredSize ();
201203 }
202204
203205
@@ -442,7 +444,12 @@ public void initFrame(final PApplet sketch) {/*, int backgroundColor,
442444
443445 // disabling resize has to happen after pack() to avoid apparent Apple bug
444446 // https://github.com/processing/processing/issues/506
445- frame .setResizable (false );
447+ // Must use this.resizable to avoid bug where value is set before initFrame is finished
448+ // https://github.com/processing/processing4/issues/1003
449+ System .out .println ("Resizable in initFrame: " + this .resizable );
450+ // setResizable(this.resizable);
451+ // frame.setResizable(true);
452+ // frame.setResizable(this.resizable);
446453
447454 frame .addWindowListener (new WindowAdapter () {
448455 @ Override
@@ -484,11 +491,18 @@ public void setTitle(String title) {
484491 /** Set true if we want to resize things (default is not resizable) */
485492 @ Override
486493 public void setResizable (boolean resizable ) {
487- // this.resizable = resizable; // really only used for canvas
494+ this .resizable = resizable ; // we need to store this so if frame init is not complete then we know the value
488495
496+ System .out .println ("Frame in setResizable:" + frame );
489497 if (frame != null ) {
490- frame .setResizable (resizable );
498+ frame .setResizable (this .resizable );
499+ System .out .println ("PSurfaceAWT.frame.resizable set to:" + frame .isResizable ());
500+ // frame.isValid();
501+ frame .validate ();
502+ System .out .println ("PSurfaceAWT.frame.isValid():" + frame .isValid ());
491503 }
504+
505+ System .out .println ("PSurfaceAWT.resizable set to:" + this .resizable );
492506 }
493507
494508
0 commit comments