Canvas problem

hello everybody i am new here and my problem is that when i am trying to draw a polygon using Canvas class and Jframe class and stuff i get the Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException problem my code is this:

Anyone can help please thx

class buildSweep extends Canvas {

String [] temp;

/**GUI variables declared*/

Canvas can = new Canvas();

Container cot = new Container();

Graphics2D neo ;

JFrame frame = new JFrame();

buildSweep(String s [][]){

temp = s;

draw(temp);

}

public void draw(String temp [][] ){

can.setSize(600,600);

int x1 = Integer.parseInt(temp[1][0]);

int y1 = Integer.parseInt(temp[1][1]);

int x2 = Integer.parseInt(temp[2][0]);

int y2 = Integer.parseInt(temp[2][1]);

int x3 = Integer.parseInt(temp[3][0]);

int y3 = Integer.parseInt(temp[3][1]);

int x4 =Integer.parseInt(temp[4][0]);

int y4=Integer.parseInt(temp[4][1]);

int x5=Integer.parseInt(temp[5][0]);

int y5=Integer.parseInt(temp[5][1]);

int x6=Integer.parseInt(temp[6][0]);

int y6=Integer.parseInt(temp[6][1]);

int x7=Integer.parseInt(temp[7][0]);

int y7=Integer.parseInt(temp[7][1]);

int x8=Integer.parseInt(temp[8][0]);

int y8=Integer.parseInt(temp[8][1]);

int [] totalx = {x1,x2,x3,x4,x5,x6,x7,x8};

int [] totaly = {y1,y2,y3,y4,y5,y6,y7,y8};

neo.drawPolygon(totalx,totaly,16);

can.paint(neo);

cot.add(can);

frame.setContentPane(cot);

frame.pack();

frame.show();

}

}

[1621 byte] By [cs02as1a] at [2007-11-26 15:25:41]
# 1
That's not how you draw. I suggest you take the 2D graphics tutorial: http://java.sun.com/docs/books/tutorial/2d/index.html
DrLaszloJamfa at 2007-7-8 21:41:17 > top of Java-index,Java Essentials,New To Java...
# 2
ok thx
cs02as1a at 2007-7-8 21:41:17 > top of Java-index,Java Essentials,New To Java...
# 3
the thing is that it doesn't show how to draw a graph in java and that is what i want to do from the beginning
cs02as1a at 2007-7-8 21:41:17 > top of Java-index,Java Essentials,New To Java...
# 4
> the thing is that it doesn't show how to draw a graph> in java and that is what i want to do from the> beginningYou need to learn to flap your wings before you can soar little eagle.
cotton.ma at 2007-7-8 21:41:17 > top of Java-index,Java Essentials,New To Java...
# 5
YEAH that is true!! but the thing is that i am following everything that the tutorial says and still i get that nullexception error! and the thing is that i dont even know what it stands for because i have no value that is null or something
cs02as1a at 2007-7-8 21:41:17 > top of Java-index,Java Essentials,New To Java...
# 6

> YEAH that is true!! but the thing is that i am

> following everything that the tutorial says and still

> i get that nullexception error! and the thing is that

> i dont even know what it stands for because i have no

> value that is null or something

Your Graphics2D reference neo is null.

cotton.ma at 2007-7-8 21:41:17 > top of Java-index,Java Essentials,New To Java...
# 7
why it's an abstract class so i dont have to create an object?
cs02as1a at 2007-7-8 21:41:17 > top of Java-index,Java Essentials,New To Java...
# 8

class buildSweep {

String [][] temp;

/**GUI variables declared*/

Canvas can = new Canvas();

Container cot = new Container();

Graphics2D neo ;

JFrame frame = new JFrame();

buildSweep(String s [][]){

temp = s;

draw(temp);

}

public void draw(String temp [][] ){

can.setSize(600,600);

int x1 = Integer.parseInt(temp[1][0]);

int y1 = Integer.parseInt(temp[1][1]);

int x2 = Integer.parseInt(temp[2][0]);

int y2 = Integer.parseInt(temp[2][1]);

int x3 = Integer.parseInt(temp[3][0]);

int y3 = Integer.parseInt(temp[3][1]);

int x4 =Integer.parseInt(temp[4][0]);

int y4=Integer.parseInt(temp[4][1]);

int x5=Integer.parseInt(temp[5][0]);

int y5=Integer.parseInt(temp[5][1]);

int x6=Integer.parseInt(temp[6][0]);

int y6=Integer.parseInt(temp[6][1]);

int x7=Integer.parseInt(temp[7][0]);

int y7=Integer.parseInt(temp[7][1]);

int x8=Integer.parseInt(temp[8][0]);

int y8=Integer.parseInt(temp[8][1]);

//System.out.println(x8+" "+y8);//+" "+x2+" "+y2+" "+x3+" "+y3+" "+x4+y4+x5+y5+x6+y6+x7+y7);

int totalx [] = {x1,x2,x3,x4,x5,x6,x7,x8};

int totaly [] = {y1,y2,y3,y4,y5,y6,y7,y8};

GeneralPath polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO, totalx.length);

polygon.moveTo(totalx[0], totaly[0]);

for (int index = 1; index < totalx.length; index++) {

polygon.lineTo(totalx[index], totaly[index]);

}

polygon.closePath();

neo.draw(polygon);

HOW ABOUT THIS

cs02as1a at 2007-7-8 21:41:17 > top of Java-index,Java Essentials,New To Java...