I draw a triangle using line. How can I fill color on it? So far I can only success color the line but not fill the color.
public void paintComponent(Graphics g){ super.paintComponents(g); int k=0; for (j=0 ; j < numOfLines; j++){ // the values of numOfLines retrieved from other method. g.setColor(Color.green); g.drawLine(x[k], x[k+1], x[k+2], x[k+3]); k = k+4; //index files }
Make a
Polygonfrom the vertices and fill that instead, by callingfillPolygon(...):