public void toggle()
{
up = !up;
if (up) {
setImage(downImage);
int x = (MIN_X + (int) (RANGE_X/ 2));
this.val = val;
value.setText (""+val);
if (val < min || val > max) {
System.err.println("Value for slider out of range (" + val + ") - ignored");
return;
}
}
else {
setImage(downImage);
}
}
public void setValueFromX(int x)
{
x -= getX(); // convert from absolute to relative offset
val = min + (int) ( (x - MIN_X) * ( range / RANGE_X) );
value.setText (""+val);
}
Here is the code I have so far. I need to reset the amplitude, frequency and damping values for a wave (like a sin or cos wave on a graph) to their initial values (the middle values on their respective "sliders" at the top of my screen). Currently, I have a switch that goes up and down, but when I click the switch, the values do not return to their initial position and my program stops. Any suggestions? Thanks!