Set Window's Minimum size when using P2D

Hi there - I’d like to resurrect this old post as the original question was not really addressed

here is some sample code

import processing.awt.PSurfaceAWT.SmoothCanvas;
import javax.swing.JFrame;
import java.awt.Dimension;

final static int minWidth=300;
final static int minHeight=300;

void settings() {
  size(500, 500); // will work
  // size(500, 500, P2D); // will fail @build time: ClassCastException: com.jogamp.newt.opengl.GLWindow cannot be cast to processing.awt.PSurfaceAWT$SmoothCanvas
}

void setup() {
  surface.setResizable(true);
  surface.setTitle("Testing Resize");
  surface.setLocation(10, 10);

  SmoothCanvas sc = (SmoothCanvas) getSurface().getNative();
  JFrame jf = (JFrame) sc.getFrame();
  jf.setMinimumSize(new Dimension(minWidth, minHeight));
}

void draw() {
  if ((width <= minWidth) && (height <= minHeight)) background(0xFFFF0000);
  else background(0xFF0000FF);
}

when building with size(500, 500); all is fine, but if I switch to size(500, 500, P2D); it will fail with

ClassCastException: com.jogamp.newt.opengl.GLWindow cannot be cast to processing.awt.PSurfaceAWT$SmoothCanvas

this is pretty self explanatory, clearly the window is no longer of the same type and we have a * com.jogamp.newt.opengl.GLWindow* but looking at its documentation I did not find anything related to setting a minimum size.

any hint appreciated if you got this to work.

thanks

Jay.