private Point addPoint(Polygon arrow,Rectangle rect,int pos,boolean from){
  int x=rect.x;
  int y=rect.y;
  Point point=null;
  if (pos == SwingConstants.TOP) {
    x+=rect.width / 2;
    if (from) {
      arrow.addPoint(x - 2,y);
      arrow.addPoint(x + 2,y);
    }
 else     arrow.addPoint(x,y);
    point=new Point(x,y - 2);
  }
 else   if (pos == SwingConstants.RIGHT) {
    x+=rect.width;
    y+=rect.height / 2;
    if (from) {
      arrow.addPoint(x,y - 2);
      arrow.addPoint(x,y + 2);
    }
 else     arrow.addPoint(x,y);
    point=new Point(x + 2,y);
  }
 else   if (pos == SwingConstants.LEFT) {
    y+=rect.height / 2;
    if (from) {
      arrow.addPoint(x,y - 2);
      arrow.addPoint(x,y + 2);
    }
 else     arrow.addPoint(x,y);
    point=new Point(x - 2,y);
  }
 else {
    x+=rect.width / 2;
    y+=rect.height;
    if (from) {
      arrow.addPoint(x - 2,y);
      arrow.addPoint(x + 2,y);
    }
 else     arrow.addPoint(x,y);
    point=new Point(x,y + 2);
  }
  return point;
}

private Point addPoint ( Polygon arrow , Rectangle rect , int pos , boolean from ) { int x = rect . x ; int y = rect . y ; Point point = null ; if ( pos == SwingConstants . TOP ) { x += rect . width / 2 ; if ( from ) { arrow . addPoint ( x - 2 , y ) ; arrow . addPoint ( x + 2 , y ) ; } else arrow . addPoint ( x , y ) ; point = new Point ( x , y - 2 ) ; } else if ( pos == SwingConstants . RIGHT ) { x += rect . width ; y += rect . height / 2 ; if ( from ) { arrow . addPoint ( x , y - 2 ) ; arrow . addPoint ( x , y + 2 ) ; } else arrow . addPoint ( x , y ) ; point = new Point ( x + 2 , y ) ; } else if ( pos == SwingConstants . LEFT ) { y += rect . height / 2 ; if ( from ) { arrow . addPoint ( x , y - 2 ) ; arrow . addPoint ( x , y + 2 ) ; } else arrow . addPoint ( x , y ) ; point = new Point ( x - 2 , y ) ; } else { x += rect . width / 2 ; y += rect . height ; if ( from ) { arrow . addPoint ( x - 2 , y ) ; arrow . addPoint ( x + 2 , y ) ; } else arrow . addPoint ( x , y ) ; point = new Point ( x , y + 2 ) ; } return point ; }
get point of rectangle
