Drawing a Line
by, 03-06-2012 at 08:46 PM (482 Views)
Line2D class is used to present the line segment(x,y) in coordinate space. To specify the lines in double precision & float, use these lines.
Code below explains the drawing of a line.
Different setline() methods are used by the Line class for explaining end points of line. End point of line will be specified by this given code. This is done by usage of constructor, for class Line2D.Float.Java Code:// draw Line2D.Double g2.draw(new Line2D.Double(x1, y1, x2, y2));
- Line2D.Float(float X1, float Y1, float X2, float Y2)
- Line2D.Float(Point2D p1, Point2D p2)
Line path stroke is defined by using the stroke object which is present in Graphics2D class.