Slider.horizontalThumbIcon
import java.awt.BorderLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JSlider;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
public class MainClass {
public static void main(String args[]) throws Exception {
JFrame frame = new JFrame("Icon Slider");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Icon icon = new ImageIcon("logo.gif");
UIDefaults defaults = UIManager.getDefaults();
defaults.put("Slider.horizontalThumbIcon", icon);
JSlider aJSlider = new JSlider();
aJSlider.setPaintTicks(true);
frame.add(aJSlider, BorderLayout.NORTH);
frame.setSize(300, 200);
frame.setVisible(true);
}
}
Related examples in the same category