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

  • Home
  • SEARCH
  • 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 to draw triangle wave (symmetrical) using ZedGraph ? alt text http://img101.imageshack.us/img101/8482/okr20troj.jpg Preferably with
How I can draw a Pascal's triangle in PASCAL Programming like a diamond from
I want to draw a custom line cap - a equilateral triangle with the
I draw an triangle using these piece of code CGPoint center; center = CGPointMake(x1,
I'm using php and gd library to draw a triangle. I'm able to draw
How to draw a triangle using SlimDX's Direct2D interface given triangle vertices are given
I draw a triangle using mouse drag. After drawing many different triangles, I wanted
I have problem with displaying all the triangles. I draw a triangle using mouse
UPDATE: Summary: I can draw a circle using TRIANGLE_FAN and, separately, I also can
Currently i am working in simple game app using openGLES, draw a line using

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.