I'm making a graphing calculator because my comp sci teacher said if i can prove i know all the topics that will be taught in the class he'll pass me for the rest of the year, so my idea is a graphing calculator, and I'm trying to put my applet mumbo jumbo in a different class. But after what i feel is doing things properly, i get an error when trying to use a method from my class with the applet. Both of these classes are in same package. Here's the class i'm calling from: (Also I imported java.awt.* already)
public class NumberCalc {
//Bunch of variable for calculator
Graphics page;
static GraphingCalc graph = new GraphingCalc();
/* Blah blah calculator shit for miles
* main method is in here with the drawGraph method
*
*/
public static void drawGraph() {
graph.addPoint(20,20,5,5);
//Test method to see if it draws, next class has the info
}
}
And here is the class I'm calling to:
public class GraphingCalc {
Graphics page;
//Code that doesnt matter right now
public void addPoint(int x, int y, int sizeA, int sizeB) {
setBackground(color.black);
page.setColor(color.cyan) //Easy to see color for testing
page.fillOval(x,y,sizeA,sizeB);
}
}
And the error i get thrown is this:
Exception in thread main java.lang.NullPointerException
at calculator.GraphingCalc.addPoint(GraphingCalc:18)
line 18 is page.setColor(color.cyan), and if i comment out this line and go to the fillOval, then it gives the same error, so there is obviously something wrong with the 'page' graphics variable. Any solutions?