0

When I slide the JSlider to the right, the left portion becomes filled with a color. Is it possible to not have it filled, and if so, how would I do so?

This is my code right now:

public void drawSlider() {
    JSlider slider = new JSlider(JSlider.HORIZONTAL, 1, 10, 5);
    slider.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    slider.setPaintLabels(true);
    slider.setMajorTickSpacing(1);
    slider.setPaintTicks(true);
    slider.setBounds(56, 293, 224, 65);
    this.getContentPane().add(slider);
}
Honinbo Shusaku
  • 1,411
  • 2
  • 27
  • 45

1 Answers1

2

You could do

slider.putClientProperty("JSlider.isFilled", Boolean.FALSE);
Reimeus
  • 158,255
  • 15
  • 216
  • 276
  • Thank you, that's what I was looking for, but I can't tell if my eyes are playing a trick on me, but the border of the sliderbox (not the etched border) itself seems to turn blue as I slide it, while staying unfilled. – Honinbo Shusaku Mar 17 '14 at 21:21
  • your eyes dont deceive, dont know of any reliable way to remove this color except to use a custom slider such as [this](http://stackoverflow.com/questions/6992633/painting-the-slider-icon-of-jslider#6992829) – Reimeus Mar 17 '14 at 22:02
  • thank you for that gem of a topic, but I guess the blue border will have to do for now. – Honinbo Shusaku Mar 17 '14 at 22:29