Hello!
I have been stuck for a while with a NullPointer:
This is not my main sketch window, I am just calling it.The file "test.png" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
The file test.png IS located in my Sketch folder 100% sure. I also tried dragging and dropping to add it to the Sketch. I don't know what can be wrong. Can somebody please help?
EDIT: Things that may help solve my problem:
1. I use some other images in other classes (windows) in my sketch and they work, so that's not a path problem. (
http://processing.org/discourse/beta/num_1268452997.html )
2. I tried putting the file in the data folder and referencing to "data/test.png", but this doesn't work either. (
http://forum.processing.org/topic/i-really-need-some-help-please-cube-with-pictures )
3. I have also tried reading a different image e.g. JPG, doesn't work too.
- public class LoadingWindow extends PApplet {
- PFont fnt;
- int W,H,PX,PY;
- PImage img;
- LoadingWindow(int w, int h) {
- fnt = fnt;
- W = w;
- H = h;
- PX = screen.width/2-W/2;
- PY = screen.height/2-H/2;
- frame = new Frame();
- frame.setBounds(0, 0, width, height);
- frame.add(this);
- this.init();
- frame.show();
- frameRate(25);
- }
- void setup() {
- // Normally, Processing will not create a frame smaller than ~120x120,
- // but will pad the window with blank pixels
- size(W,H);
- fnt = createFont("Helvetica", 12, false);
- img = loadImage("test.png");
- }
- // overriding PApplet.init() to add a hack of our own
- void init() {
- frame.removeNotify();
- frame.setUndecorated(true);
- frame.setAlwaysOnTop(true);
- frame.setResizable(true);
- frame.addNotify();
- super.init();
- }
- void draw() {
- background(0);
- if(frameCount==5) {
- frame.resize(W,H);
- frame.setLocation(PX,PY);
- }
- image(img, 10, 10);
- }
- }
1