We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm creating a program that uses multiple windows.
I finally figured out how to create the second window using the code from here.
But when I try to load a picture into it I get a null Pointer exception despite the fact that the image is in the data folder and the named correctly. Any idea why?
//here's the class itself
class PWindow extends PApplet {
// PImage[] subs = new PImage[2];
// String testKey="m";
PWindow() {
super();
PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
}
void settings() {
size(1920, 1080);
}
void setup() {
background(150);
subs[0]=loadImage("test.png");
}
void draw() {
if (keyPressed && key == testKey.charAt(0)){
image(subs[0], 0,0);
println("well it works");
}
}
void mousePressed() {
println("mousePressed in secondary window");
}
}
Answers
https://Forum.Processing.org/two/discussion/25448/can-t-load-image#Item_2
Check this: https://forum.processing.org/two/discussion/comment/72574/#Comment_72574
Kf
Thanks for those. So what I got from the second link is that I have to load files outside of the second applet and then draw them in it. I don't understand why but it works. Thank you!