Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 154631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:00:47+00:00 2026-05-11T10:00:47+00:00

I draw a triangle using line. How can I fill color on it? So

  • 0

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         } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:00:48+00:00Added an answer on May 11, 2026 at 10:00 am

    Make a Polygon from the vertices and fill that instead, by calling fillPolygon(...):

    // A simple triangle. x[0]=100; x[1]=150; x[2]=50; y[0]=100; y[1]=150; y[2]=150; n = 3;  Polygon p = new Polygon(x, y, n);  // This polygon represents a triangle with the above                                    //   vertices.  g.fillPolygon(p);     // Fills the triangle above. 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I draw something in JPanel that will stay the same and not
How can i draw a dotted line in .NET/WinForms/GDI+? Pen p = new Pen
I want to draw a custom line cap - a equilateral triangle with the
I draw a triangle using mouse drag. After drawing many different triangles, I wanted
I draw an triangle using these piece of code CGPoint center; center = CGPointMake(x1,
I'm trying to draw a polygon using c# and directx All I get is
Where do you draw the line to stop making abstractions and to start writing
I draw many triangle polygons and store it in Linked List. My problem is
How to move a triangle to a new location using mouse drag (which was
I'm using OpenGL ES on Android to draw some shapes, so I have some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.