Loading images to a second applet?

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

Sign In or Register to comment.