I have some code for a changeListener below. Basically I need to set the value of my Voltage variable to the value which my JSlider is currently positioned at. So if my slider was at 5 then my variable Voltage would read 5. However this does not happen and I am unsure why. Whats missing which would set the variable to have the current value that my JSlider is at?
public double getVoltageFromSlider() {
sliders.voltageSlider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent event) {
Voltage = (double) event.getSource();
Voltage = sliders.voltageSlider.getValue();
}
});
return Voltage;
}