Asked • 05/02/19

How to fill color on triangle?

I draw a triangle using line. How can I fill color on it? So far I can only 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 } }

1 Expert Answer

By:

Shreya R. answered • 05/21/19

Tutor
0 (0)

CS Major (proficient in C/Java) and versed Spanish/Math tutor

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.