public static Image dropshadow(Image source,int blurRadius,float opacity,int xDistance,int yDistance){
  Image s=dropshadow(source,blurRadius,opacity);
  Image n=Image.createImage(source.getWidth() + Math.abs(xDistance),source.getHeight() + Math.abs(yDistance),0);
  Graphics g=n.getGraphics();
  int shadowX=0, imageX=0, shadowY=0, imageY=0;
  if (xDistance < 0) {
    imageX=xDistance * -1;
  }
 else {
    shadowX=xDistance;
  }
  if (yDistance < 0) {
    imageY=yDistance * -1;
  }
 else {
    shadowY=yDistance;
  }
  g.drawImage(s,shadowX,shadowY);
  g.drawImage(source,imageX,imageY);
  return n;
}

public static Image dropshadow ( Image source , int blurRadius , float opacity , int xDistance , int yDistance ) { Image s = dropshadow ( source , blurRadius , opacity ) ; Image n = Image . createImage ( source . getWidth ( ) + Math . abs ( xDistance ) , source . getHeight ( ) + Math . abs ( yDistance ) , 0 ) ; Graphics g = n . getGraphics ( ) ; int shadowX = 0 , imageX = 0 , shadowY = 0 , imageY = 0 ; if ( xDistance < 0 ) { imageX = xDistance * - 1 ; } else { shadowX = xDistance ; } if ( yDistance < 0 ) { imageY = yDistance * - 1 ; } else { shadowY = yDistance ; } g . drawImage ( s , shadowX , shadowY ) ; g . drawImage ( source , imageX , imageY ) ; return n ; }
generates a shadow for the source image and returns a new larger image containing the shadow
