2

I have a JSlider and I want to make it so I can not move it with my mouse. Instead I have set the Slider to interact with update methods determined by observables. So if slider is 3 one time and then I click a JButton and some value changes to 4 the Slider moves.

The Slider already functions like this, but what I need is a way to make it so I can't move it with my mouse. I can't

//pseudo

JSlider slide = new JSlider(0, 4, e.getVal) //val is 3
//JSlider can't move with mouse
//call update
void update()
 slide.setValue(e.getVal); //val is 4

This is a basic idea of what I want. Any ideas?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
user3466773
  • 176
  • 1
  • 2
  • 14
  • 3
    Why you can't just disable it use [setEnabled](http://docs.oracle.com/javase/7/docs/api/javax/swing/JComponent.html#setEnabled%28boolean%29) method? – Maxim Feb 28 '15 at 13:53
  • 1
    Because I never heard of that before is the honest answer haha There's easily 100+ concepts in the full program I'm implementing, a lot of it is just researching. Could I ask how I would invoke setEnabled in this case? – user3466773 Feb 28 '15 at 13:56
  • 1
    Put `slide.setEnabled(false);` after initialization of `slide` variable. – Maxim Feb 28 '15 at 13:58
  • Nevermind, I got it. I do slider.setEnabled(false); Thanks for the tip! – user3466773 Feb 28 '15 at 13:58

0 Answers0