M
mcdeveloper
Hi all,
I 've got this strange (?) problem. I call a method from javascript, setting a private member variable USERENTERED. Within the method, everything goes fine, if I print the variable it has changed. However, as soon as I use the variable in another method, it has changed back to its initial value (which is -1 in my case).
I don't see what I'm doing wrong, the variable is not local but a member variable. This is the method being called:
public void setUserEnteredValue(String x)
{
try
{
double d = Double.parseDouble(x);
int xPos = (int)((d * FACTOR) + MARGINLEFT - (SCALEMIN * FACTOR));
this.USERENTERED = xPos;
System.out.println("User entered" + USERENTERED);
}
catch (NumberFormatException nfe) { System.out.println("failed to set user input, input is " + x ); }
}
If the variable is made static, it DOES change, but this is undesired because (of course) all other instances of the applet will have a changed variable. I'm not setting the variable elsewere. Morveover, I'm using this technique for other variables as well and I've got the same problem with those.
Any ideas?
MC.
I 've got this strange (?) problem. I call a method from javascript, setting a private member variable USERENTERED. Within the method, everything goes fine, if I print the variable it has changed. However, as soon as I use the variable in another method, it has changed back to its initial value (which is -1 in my case).
I don't see what I'm doing wrong, the variable is not local but a member variable. This is the method being called:
public void setUserEnteredValue(String x)
{
try
{
double d = Double.parseDouble(x);
int xPos = (int)((d * FACTOR) + MARGINLEFT - (SCALEMIN * FACTOR));
this.USERENTERED = xPos;
System.out.println("User entered" + USERENTERED);
}
catch (NumberFormatException nfe) { System.out.println("failed to set user input, input is " + x ); }
}
If the variable is made static, it DOES change, but this is undesired because (of course) all other instances of the applet will have a changed variable. I'm not setting the variable elsewere. Morveover, I'm using this technique for other variables as well and I've got the same problem with those.
Any ideas?
MC.