It really doesn’t like that undecorated frame. I don’t recall seeing that on Windows11. When you state that there was no red status in console bar does that mean that the window is formed ok and it’s more of a warning or is the window not formed and it’s more of an exception? If you can’t use the window 50% of the time that’s a problem. I thought that rearranging the code had fixed it, but apparently not on Windows 10. The only way to really solve this is to figure out BufferStrategy and save that before undecorating the frame; so far I haven’t been able to do that. Thanks for the feedback; always appreciated.
Just to verify the above, the following code should run without error on Windows 10:
import java.awt.*;
Window wnd;
class Window extends PApplet {
Frame frame;
Canvas canvas;
int x, y, w, h;
color bkgrnd;
public Window(int x, int y, int w, int h, color bkgrnd) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.bkgrnd = bkgrnd;
PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
frame = ((processing.awt.PSurfaceAWT.SmoothCanvas) surface.getNative()).getFrame();
canvas = (processing.awt.PSurfaceAWT.SmoothCanvas) surface.getNative();
frame.setLocation(x,y);
println(canvas);
}
void settings() { // Necessary for PApplet
size(w, h); // Sets canvas size
}
void setup() {
background(bkgrnd);
surface.setResizable(true);
}
void draw() {
fill(0, 255, 0);
rect(30, 50, 100, 30);
fill(0);
textSize(18.0);
textAlign(CENTER, CENTER);
text("MyBtn", 30, 50-2, 100, 30);
}
void mousePressed() {
if ((mouseX >= 30) && (mouseX <= 30 + 100) && (mouseY >= 50) && (mouseY <= 50 + 30)) {
println("button hit.");
}
}
}
// **** Default Window **** //
void setup() {
size(400, 400);
surface.setTitle("Default Window");
wnd = new Window(100, 100, 300, 300, color(0));
}
void draw() {
fill(255, 0, 0);
circle(width/2, height/2, 200);
}
void mousePressed() {
println("mousePressed in default window");
}