@Override public void paint(Graphics g,JComponent c){
  super.paint(g,c);
  Rectangle clipRect=g.getClipBounds();
  if (upperThumbSelected) {
    if (clipRect.intersects(thumbRect)) {
      paintLowerThumb(g);
    }
    if (clipRect.intersects(upperThumbRect)) {
      paintUpperThumb(g);
    }
  }
 else {
    if (clipRect.intersects(upperThumbRect)) {
      paintUpperThumb(g);
    }
    if (clipRect.intersects(thumbRect)) {
      paintLowerThumb(g);
    }
  }
}

@ Override public void paint ( Graphics g , JComponent c ) { super . paint ( g , c ) ; Rectangle clipRect = g . getClipBounds ( ) ; if ( upperThumbSelected ) { if ( clipRect . intersects ( thumbRect ) ) { paintLowerThumb ( g ) ; } if ( clipRect . intersects ( upperThumbRect ) ) { paintUpperThumb ( g ) ; } } else { if ( clipRect . intersects ( upperThumbRect ) ) { paintUpperThumb ( g ) ; } if ( clipRect . intersects ( thumbRect ) ) { paintLowerThumb ( g ) ; } } }
paints the slider . the selected thumb is always painted on top of the other thumb .
