Here you can find the source of drawArrow(Graphics g, Point from, Point to)
public static void drawArrow(Graphics g, Point from, Point to)
//package com.java2s; //License from project: Apache License import java.awt.Graphics; import java.awt.Point; public class Main { public static void drawArrow(Graphics g, Point from, Point to) { int arrowLength = 10; int deltaX = to.x - from.x; int deltaY = to.y - from.y; float length = (float) Math.sqrt(deltaX * deltaX + deltaY * deltaY); Point toRotate = new Point(); toRotate.x = Math.round(0 - (arrowLength * deltaX) / length); toRotate.y = Math.round(0 - (arrowLength * deltaY) / length); Point one = rotate(toRotate, (float) Math.toRadians(20)); Point two = rotate(toRotate, (float) Math.toRadians(-20)); one.x += to.x;// w w w .j a v a 2 s . c om one.y += to.y; two.x += to.x; two.y += to.y; // draw arrow g.drawLine(one.x, one.y, to.x, to.y); g.drawLine(two.x, two.y, to.x, to.y); } public static Point rotate(Point toRotate, float tetta) { float sin = (float) Math.sin(tetta); float cos = (float) Math.cos(tetta); int x = (int) (toRotate.x * cos - toRotate.y * sin); int y = (int) (toRotate.x * sin + toRotate.y * cos); return new Point(x, y); } }