java 2D

Hello Java Friends,

I wanted to draw a shape e.g. (triangle or a figure with more nodes) and then connect each node to the rest nodes with a line. It works only up to 3 nodes (triangle). Can someone give me some idea on how to solve the problem.

See code below:

//draw the line

GeneralPath circleLine =new GeneralPath(GeneralPath.WIND_EVEN_ODD, xPoints.length);

circleLine.moveTo(xPoints[0]+ circleSize[0]/2, yPoints[0] + circleSize[0]/2);

g2d.setColor(Color.green);

g2d.setStroke(new BasicStroke(1));

for (int index = 1; index < xPoints.length; index++){

for (int indey = 1; indey < yPoints.length; indey++){

circleLine.lineTo(xPoints[indey] + circleSize[0]/2, yPoints[indey] + circleSize[0]/2);

}

}

circleLine.closePath();

g2d.draw(circleLine);

Thanks,

Jona_T

[1213 byte] By [Jona_Ta] at [2007-11-26 23:55:15]
# 1
There's a forum just for Java 2D questions.You'll have more luck there: http://forum.java.sun.com/forum.jspa?forumID=20
DrLaszloJamfa at 2007-7-11 15:38:54 > top of Java-index,Java Essentials,Java Programming...