Using an image for the slider knob in a JSlider


You could override the default JSlider Icons that are used using UIManager.put. Just because this is what happens inside the Slider UI classes:
    Icon horizThumbIcon = UIManager.getIcon( "Slider.horizontalThumbIcon" );
    Icon vertThumbIcon = UIManager.getIcon( "Slider.verticalThumbIcon" );

This would make the image that is used as the thumb the same for all JSliders you make.

Another way is to create your own UI (and hence breaking LAF capabilities). In the following example, I override the two methods paintThumb and getThumbSize.

Main.java:

import javax.swing.plaf.metal.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
    
public class Main extends JFrame {
   public Main() {
      getContentPane().setLayout(new FlowLayout());
  
      final JSlider hslider = new JSlider(JSlider.HORIZONTAL, 0, 30, 15);
      final JSlider vslider = new JSlider(JSlider.VERTICAL, 0, 30, 15);
      // draw the major tick marks (one for every tick label)
      hslider.setMajorTickSpacing(10);
      vslider.setMajorTickSpacing(10);
      // draw the minor tick marks (between the tick labels)
      hslider.setMinorTickSpacing(1);
      vslider.setMinorTickSpacing(1);
      // draw the tick marks
      hslider.setPaintTicks(true);
      vslider.setPaintTicks(true);
      // draw the tick mark labels
      hslider.setPaintLabels(true);
      vslider.setPaintLabels(true);
  
      getContentPane().add(hslider);
      getContentPane().add(vslider);
   
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent event) {
            System.exit(0);   
         }      
      });
  
      Icon maleIcon   = new ImageIcon("male.gif");
      Icon femaleIcon = new ImageIcon("female.gif");
 
      hslider.setUI(new IconThumbSliderUI(maleIcon, femaleIcon));
      vslider.setUI(new IconThumbSliderUI(maleIcon, femaleIcon));
      pack();
   }
  
   public static void main(String[] args) {
      (new Main()).show();
   }
}
  
class IconThumbSliderUI extends MetalSliderUI {
    protected Icon hThumbIcon = null;
    protected Icon vThumbIcon = null;
  
    public IconThumbSliderUI(Icon hThumbIcon, Icon vThumbIcon) {
        setHorizontalThumbIcon(hThumbIcon);
        setVerticalThumbIcon(vThumbIcon);
    }
  
    public void setHorizontalThumbIcon(Icon hThumbIcon) {
       if (hThumbIcon == null) this.hThumbIcon = horizThumbIcon;
       else                    this.hThumbIcon = hThumbIcon;
    }
 
    public void setVerticalThumbIcon(Icon vThumbIcon) {
       if (vThumbIcon == null) this.vThumbIcon = vertThumbIcon;
       else                    this.vThumbIcon = vThumbIcon;
 
    }
 
    public void paintThumb(Graphics g)  {
        Rectangle knobBounds = thumbRect;
 
        g.translate( knobBounds.x, knobBounds.y );
 
        if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
            hThumbIcon.paintIcon( slider, g, 0, 0 );
        }
        else {
            vThumbIcon.paintIcon( slider, g, 0, 0 );
        }
  
        g.translate( -knobBounds.x, -knobBounds.y );
    }
 
    protected Dimension getThumbSize() {
        Dimension size = new Dimension();
 
        if ( slider.getOrientation() == JSlider.VERTICAL ) {
	    size.width = vThumbIcon.getIconWidth();
	    size.height = vThumbIcon.getIconHeight();
	}
	else {
	    size.width = hThumbIcon.getIconWidth();
	    size.height = hThumbIcon.getIconHeight();
	}
 
	return size;
    }
}

Images used in this example: