This section illustrates you how to draw a triangle using a Line2D.
To draw a triangle, we are using Line2D class of package java.awt.geom.*. This class provides a line segment in (x, y) coordinate space. We have draw three line segments using the class Line2D to create a triangle.
The setPaint() method paints the line segment.
Here is the code of DrawTriangleUsingLine.java
import java.awt.*;
|
Output will be displayed as:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Draw a Triangle using a Line2D
Post your Comment