public void paintComponentBackground(Graphics g){
  super.paintComponentBackground(g);
  int clipX=g.getClipX();
  int clipY=g.getClipY();
  int clipW=g.getClipWidth();
  int clipH=g.getClipHeight();
  int width=getWidth();
  int height=getHeight();
  int y=getY();
  if (infinite) {
    int blockSize=getWidth() / 5;
    int x=getX() + (int)((((float)value) / ((float)maxValue - minValue)) * (getWidth() - blockSize));
    g.clipRect(x,y,blockSize,height - 1);
  }
 else {
    if (vertical) {
      int actualHeight=(int)((((float)value) / ((float)maxValue - minValue)) * getHeight());
      y+=height - actualHeight;
    }
 else {
      width=(int)((((float)value) / ((float)maxValue - minValue)) * getWidth());
    }
    g.clipRect(getX(),y,width,height);
  }
  paintingFull=true;
  super.paintComponentBackground(g);
  paintingFull=false;
  g.setClip(clipX,clipY,clipW,clipH);
  if (thumbImage != null && !infinite) {
    if (!vertical) {
      int xPos=getX() + width - thumbImage.getWidth() / 2;
      xPos=Math.max(getX(),xPos);
      xPos=Math.min(getX() + getWidth() - thumbImage.getWidth(),xPos);
      g.drawImage(thumbImage,xPos,y + height / 2 - thumbImage.getHeight() / 2);
    }
 else {
      int yPos=y;
      g.drawImage(thumbImage,getX() + width / 2 - thumbImage.getWidth() / 2,yPos);
    }
  }
}

public void paintComponentBackground ( Graphics g ) { super . paintComponentBackground ( g ) ; int clipX = g . getClipX ( ) ; int clipY = g . getClipY ( ) ; int clipW = g . getClipWidth ( ) ; int clipH = g . getClipHeight ( ) ; int width = getWidth ( ) ; int height = getHeight ( ) ; int y = getY ( ) ; if ( infinite ) { int blockSize = getWidth ( ) / 5 ; int x = getX ( ) + ( int ) ( ( ( ( float ) value ) / ( ( float ) maxValue - minValue ) ) * ( getWidth ( ) - blockSize ) ) ; g . clipRect ( x , y , blockSize , height - 1 ) ; } else { if ( vertical ) { int actualHeight = ( int ) ( ( ( ( float ) value ) / ( ( float ) maxValue - minValue ) ) * getHeight ( ) ) ; y += height - actualHeight ; } else { width = ( int ) ( ( ( ( float ) value ) / ( ( float ) maxValue - minValue ) ) * getWidth ( ) ) ; } g . clipRect ( getX ( ) , y , width , height ) ; } paintingFull = true ; super . paintComponentBackground ( g ) ; paintingFull = false ; g . setClip ( clipX , clipY , clipW , clipH ) ; if ( thumbImage != null && ! infinite ) { if ( ! vertical ) { int xPos = getX ( ) + width - thumbImage . getWidth ( ) / 2 ; xPos = Math . max ( getX ( ) , xPos ) ; xPos = Math . min ( getX ( ) + getWidth ( ) - thumbImage . getWidth ( ) , xPos ) ; g . drawImage ( thumbImage , xPos , y + height / 2 - thumbImage . getHeight ( ) / 2 ) ; } else { int yPos = y ; g . drawImage ( thumbImage , getX ( ) + width / 2 - thumbImage . getWidth ( ) / 2 , yPos ) ; } } }
paint the progress indicator
