0

I have a custom component based on the JSlider. It's essentially the same thing only it has 2 thumbs, which I named a DualSlider.

I need to change the maximum value of the slider once in a while, so every time I do, I call updateUI to reflect this.

public void updateUI() {
    this.setUI(new DualSliderUI(this));
    this.updateLabelUIs();
}

However, the maximum value of the DualSlider when I try to use it is still set at the original value no matter how many times I try to change it while using my program. I can confirm with a few println statements that a new DualSliderUI is being made with the slider that has the new max value, but for whatever reason the original DualSliderUI I initialized the slider with is the one that is in use.

What other things do I have to make sure I do when I update a property so I can avoid this?

SpeedBurner
  • 711
  • 2
  • 9
  • 18

1 Answers1

1

1) I can't see reason for usage updateUI() this should be done once time, only when you built this JSlider, never do that repeately

2) you have look at BoundedRangeModel, maybe

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319