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:
Posted on: October 16, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles