well, i think i got the problem, the problem is you are thinking your origin is in the center of the cross you draw, but the origin is top-left corner of the screen, so you need to map your results to fit the screen, i don't use graphics stuff but it seems the problem...
and you need to clear the screen before repainting...
another program is x0,x1,x2,x3,x4 stuff, it will be much easy if you use an array.... you can get rid of the big if-else block in stateChange by using arrays....
public int fOfX(int x)
{
int yCoord = x4*x^4 + x3*x^3 + x2*x^2 + x1^1 + x0^0;
graph = true;
repaint();
return yCoord;
}
here fOfX calculates wrong, you need write like this,
int yCoord = x4*(x^4) + x3*(x^3) + x2*(x^2) + x1*(x^1) + x0*(x^0);
now, i am going to try to make a polynomial plotterby myself, so we can check our program better...