public void paintBorder(Component c,Graphics g,int x,int y,int width,int height){
  JComponent comp=(c instanceof JComponent) ? (JComponent)c : null;
  if (g instanceof Graphics2D) {
    Graphics2D g2=(Graphics2D)g;
    g2.translate(x,y);
    paint(g2,comp,width,height);
    g2.translate(-x,-y);
  }
 else {
    BufferedImage img=new BufferedImage(IMG_SIZE,IMG_SIZE,BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2=(Graphics2D)img.getGraphics();
    paint(g2,comp,width,height);
    g2.dispose();
    ImageScalingHelper.paint(g,x,y,width,height,img,INSETS,INSETS,ImageScalingHelper.PaintType.PAINT9_STRETCH,ImageScalingHelper.PAINT_ALL);
  }
}

public void paintBorder ( Component c , Graphics g , int x , int y , int width , int height ) { JComponent comp = ( c instanceof JComponent ) ? ( JComponent ) c : null ; if ( g instanceof Graphics2D ) { Graphics2D g2 = ( Graphics2D ) g ; g2 . translate ( x , y ) ; paint ( g2 , comp , width , height ) ; g2 . translate ( - x , - y ) ; } else { BufferedImage img = new BufferedImage ( IMG_SIZE , IMG_SIZE , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D g2 = ( Graphics2D ) img . getGraphics ( ) ; paint ( g2 , comp , width , height ) ; g2 . dispose ( ) ; ImageScalingHelper . paint ( g , x , y , width , height , img , INSETS , INSETS , ImageScalingHelper . PaintType . PAINT9_STRETCH , ImageScalingHelper . PAINT_ALL ) ; } }
paints the border for the specified component with the specified position and size .
