How do I draw a triangle?

You may use Graphics.drawPolygon(int[], int[], int) where the first int[] is the set of x values, the second int[] is the set of y values, and the int is the length of the array. (In a triangle’s case, the int is going to be 3)


graphics.drawPolygon(new int[] {10, 20, 30}, new int[] {100, 20, 100}, 3);


Leave a Comment