Welcome to JavaRanch
You might consider using the
Path2D class instead of polyLine. You can add a segment to a Path2D with the lineTo method. Note Path2D is abstract, so you have to use a subclass.
For drawing lines in an "animated" fashion, you can try the Timer class. There is a section in the
Java™ Tutorials which has something about Timers in. You can have an array of points, and on each "tick" of the Timer move to the next point in the array. Remember the number of lines is one less than the length of the array, so the number of valid ticks should be one less than the array size.
You can also use the static sleep() method of the
Thread class. Beware: I have heard there is something peculiar in some versions of Windows which causes the computer clock to show the wrong time of you sleep threads, unless the duration of sleep is a multiple of 10ms. I don't know whether that has been sorted out. You may also get problems if you stop the event dispatch thread; your GUI will be disabled for the duration of the sleeps.