1

I'm looking for a better solution than the one I currently have:

I have a textfield for which I read and right numbers in:

textStiffness.setText((""+stiffness).replaceAll(",", ""));

and

stiffness = Float.valueOf(s1.replaceAll(",", "")).floatValue();

and her you can see my problem and my work around: When I write a number over 999 it adds a "," sign that then can't be read by the Float.value(s) method.

any ideas ?

Jason

mskfisher
  • 3,291
  • 4
  • 35
  • 48
Jason Rogers
  • 19,194
  • 27
  • 79
  • 112
  • No, I can't see your problem because you didn't post a SSCCE (http://sscce.org). What does "writing a number" mean? When you type a number into a text it doesn't automatcally insert a comma. – camickr Jun 21 '11 at 03:49

1 Answers1

1

If I understood your needs, I think you should use a JFormattedTextField for a clean solution. Have a look at this tutorial .

Heisenbug
  • 38,762
  • 28
  • 132
  • 190