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
Output will be displayed as:
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: Draw a Triangle using a Line2D
Post your Comment