How do i draw a triangle in java?
问题 Ok so first of all i know how to draw a rectangle and circles and ect with g.drawRect or g.drawOval but there is no g.drawtriangle so can you guys tell me if there is a way to draw a triangle with out me having to draw it out each side of the triangle. 回答1: 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) Example: