ActionListner listener = new ActionListener()
{
public void ActionPerformed()
{
String s = msg.getText();
float f;
try{
f = Float.parseFloat(s);
}catch(NumberFormatException e){
[b]...[/b]
}
}
}
I was making a float of the string, but this should work, now you'd also want to force the user to only type valid numaric chars and the decimal point by implementing other actionlistners.
ok thanks very much, just a follow up question how can i assign a double variable to a text field? i received an error when i code the ff., just starting to use java
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.