I want to draw a directed arrow line through Java.
At present, I am using java.awt.Line2D.Double
class to draw a line
g2.setStroke(new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); // g2 is an instance of Graphics2D
g2.draw(new Line2D.Double(x1,y1,x2,y2));
But only the line appears and no directed arrow appears. BasicStroke.Join_BEVEL
is used to draw a directed arrow. It is applied when two line segments meet.
The line I am drawing meets the border of a rectangle but no directed arrow is drawn. Only a simple line is drawn.
Is there anything I am missing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…