Basically, it works if I only provide 4 xy pairs. If I add a 5th pair, it fails - "java.lang.ArrayIndexOutOfBoundsException: 4". I'm a newb, but it seems that I've provided more xy pairs than the array can hold. However, I defined polygon1.npoints=5 - so shouldn't it be able to hold 5 pairs?
So, if I have hundreds of points I want to add (from a db), I could throw them into arrays (or arrayLists) - one for x coords, one for y coords, and use a for loop to load them?
I tried this with the code below, but I'm getting an error - "The method addpoints(int, int) is undefined for the type Polygon". The method says "addPoint(int x, int y) Appends the specified coordinates to this Polygon."
What have I missed?
Thanks so much - I'm miles ahead of where I was!
Joined: May 07, 2005
I got it!
If I've got arrays of x and y coords, I can instantiate the polygon from them directly.