|
Author |
Topic: NullPointerException (Read 342 times) |
|
drh28
|
NullPointerException
« on: May 29th, 2004, 11:18pm » |
|
Here is the code that causes the error. Any feedback is greatly appreciated. BFont theFont = loadFont("Times_Italic.vlw"); textFont(theFont, 24); ellipseMode(CENTER_RADIUS); noStroke(); String[] input = loadStrings("data.txt"); println("Inputfile has " + input.length + " lines"); size(300,200); background(0); for (int i = 0; i < input.length; i++) { println("Retrieving line " + i + " '" + input[i] + "'"); String[] words = splitStrings(input[i],','); if (words.length < 2) continue; String dataSource = words[0]; int dataPoint = Integer.parseInt(words[1]); fill(240,240,240); text(dataSource, 4, (i * 20) + 16); fill(0,255,50); ellipse(dataPoint + 80 , (i * 20) + 10, 4, 2); }
|
|
|
|
sspboyd
|
Re: NullPointerException
« Reply #1 on: May 31st, 2004, 3:25pm » |
|
Make sure your data.txt file is in your sketch data folder. I just ran your code and got the same error as you but when I put a file in the data folder and called it data.txt the code works no problem.
|
gmail.com w/ sspboyd username
|
|
|
020200
|
Re: NullPointerException:
« Reply #2 on: Nov 27th, 2004, 8:39pm » |
|
I got the same error, but i can't see why! Here ist my code: Code: /////////////////////////////////////////////////////// Drawline[] dlines; int num = 20; int i; void setup() { size(400,400); framerate(25); dlines = new Drawline[num]; for(i=0; i<num; i++) { dlines = new Drawline[i]; } } /////////////////////////////////////////////////////// void loop() { background(0); dlines[1].update(); } /////////////////////////////////////////////////////// class Drawline { int mx; int my; Drawline() { mx = int(random(400)); my = int(random(400)); } void update() { stroke(245); line(mx, my, mouseX, mouseY); } } |
| The error occurs at the line: dlines[1].update(); // PLEASE HELP!!
|
|
|
|
020200
|
Re: NullPointerException
« Reply #3 on: Nov 27th, 2004, 8:46pm » |
|
Ah, i found 'em Bastard myself! Code: void setup() { size(400,400); framerate(25); dlines = new Drawline[num]; for(i=0; i<num; i++) { dlines[i] = new Drawline(); //HERE was a the (syntax) error! } } /////////////////////////////////////////////////////// void loop() { background(0); dlines[1].update(); /// this line was pretty valid! } |
|
|
|
|
|
|