public void paintBorder(Component c,Graphics g,int x,int y,int width,int height){
  Insets insets=getBorderInsets(c);
  Color oldColor=g.getColor();
  g.translate(x,y);
  if (tileIcon != null) {
    color=(tileIcon.getIconWidth() == -1) ? Color.gray : null;
  }
  if (color != null) {
    g.setColor(color);
    g.fillRect(0,0,width - insets.right,insets.top);
    g.fillRect(0,insets.top,insets.left,height - insets.top);
    g.fillRect(insets.left,height - insets.bottom,width - insets.left,insets.bottom);
    g.fillRect(width - insets.right,0,insets.right,height - insets.bottom);
  }
 else   if (tileIcon != null) {
    int tileW=tileIcon.getIconWidth();
    int tileH=tileIcon.getIconHeight();
    paintEdge(c,g,0,0,width - insets.right,insets.top,tileW,tileH);
    paintEdge(c,g,0,insets.top,insets.left,height - insets.top,tileW,tileH);
    paintEdge(c,g,insets.left,height - insets.bottom,width - insets.left,insets.bottom,tileW,tileH);
    paintEdge(c,g,width - insets.right,0,insets.right,height - insets.bottom,tileW,tileH);
  }
  g.translate(-x,-y);
  g.setColor(oldColor);
}

public void paintBorder ( Component c , Graphics g , int x , int y , int width , int height ) { Insets insets = getBorderInsets ( c ) ; Color oldColor = g . getColor ( ) ; g . translate ( x , y ) ; if ( tileIcon != null ) { color = ( tileIcon . getIconWidth ( ) == - 1 ) ? Color . gray : null ; } if ( color != null ) { g . setColor ( color ) ; g . fillRect ( 0 , 0 , width - insets . right , insets . top ) ; g . fillRect ( 0 , insets . top , insets . left , height - insets . top ) ; g . fillRect ( insets . left , height - insets . bottom , width - insets . left , insets . bottom ) ; g . fillRect ( width - insets . right , 0 , insets . right , height - insets . bottom ) ; } else if ( tileIcon != null ) { int tileW = tileIcon . getIconWidth ( ) ; int tileH = tileIcon . getIconHeight ( ) ; paintEdge ( c , g , 0 , 0 , width - insets . right , insets . top , tileW , tileH ) ; paintEdge ( c , g , 0 , insets . top , insets . left , height - insets . top , tileW , tileH ) ; paintEdge ( c , g , insets . left , height - insets . bottom , width - insets . left , insets . bottom , tileW , tileH ) ; paintEdge ( c , g , width - insets . right , 0 , insets . right , height - insets . bottom , tileW , tileH ) ; } g . translate ( - x , - y ) ; g . setColor ( oldColor ) ; }
paints the matte border .
