StackOverflowError
I'm getting an error message below and can't figure out why. The message is as follows:
Exception in thread "Thread-3" java.lang.StackOverflowError
at java.awt.geom.Ellipse2D$Float.getX(Ellipse2D.java:92)
at java.awt.geom.EllipseIterator.(EllipseIterator.java:25)
at java.awt.geom.Ellipse2D.getPathIterator(Ellipse2D.java:405)
at java.awt.geom.Path2D$Float.(Path2D.java:215)
at java.awt.geom.Path2D$Float.(Path2D.java:190)
at sun.java2d.pipe.LoopPipe.fill(LoopPipe.java:249)
at sun.java2d.pipe.LoopPipe.fillOval(LoopPipe.java:123)
at sun.java2d.SunGraphics2D.fillOval(SunGraphics2D.java:2158)
I'm getting this on the specified line of the code below (explosion[i].paintSprite(g);). If I remark out the line, or do something else with the Graphics var g, I'm good. Once I place this code back in, it breaks. Does anyone know what the problem is? Doesn't make sense.
[code]
int gravity, a, v, T, L, x, y;
explosion = new FireworksSprite[100];
double valueA, valueB, dx, dy;
int t;
Random r = new Random();
for(t = 0; t < explosion.length; t ++)
{
gravity = 20;
a = r.nextInt(50);
v = r.nextInt(50);
//System.out.println("a = " + a);
//System.out.println("v = " + v);
valueA = v*Math.sin(a)*t;
valueB = (.5)*gravity*(t*t);
dx = (int)v*Math.cos(a)*t;
dy = (int)valueA - valueB;
x = (int)dx;
y = (int)dy;
//System.out.print("Iterating through Array" + t);
explosion[t] = new FireworksSprite();
explosion[t].setSpriteH(15);
explosion[t].setSpriteW(10);
explosion[t].setLocx(x);
explosion[t].setLocy(y);
explosion[t].setActive(true);
explosion[t].setVisible(true);
explosion[t].setVel(0, v);
}
for (int i = 0; i < explosion.length; i ++)
{
explosion[i].paintSprite(g); //PROBLEM LINE IN CODE
//System.out.println("i is: " + i);
}
}
[\code]
CaffeineCoder
Junior Poster in Training
58 posts since Feb 2008
Reputation Points: 10
Solved Threads: 1
You would need to post the paintSprite() method code, as that is the one making the calls into the graphics methods that are overflowing the stack.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
You would need to post the paintSprite() method code, as that is the one making the calls into the graphics methods that are overflowing the stack.
Thanks Ezzaral, you helped. I was looking at the paintSprite() method in order to post it, and saw the problem; didn't realize it before now. Had simple logic error and am now good to go.
CaffeineCoder
Junior Poster in Training
58 posts since Feb 2008
Reputation Points: 10
Solved Threads: 1