Search code examples
java2dpolygongraphic

Draw an open Polygon in Java


I'm trying to draw an open rectangle using a Polygon:

int[] xPoints = {1,1,3,3};
int[] xPoints = {0,5,5,0};
polygone = new Polygon(xPoints, yPoints, 4);
g2d.draw(polygone);

Is there any way to have an open Polygon?


Solution

  • You might look at java.awt.geom.Path2D, used here, or java.awt.geom.GeneralPath, illustrated here.