Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to stop Values being cleared JTextField in non-english locales

 
A Khan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
--------------------------------------------------------------------------------
I have a textfield on which a float-based document model is applied such that insertString() is overloaded to check for Character.isDigit(). Character.OTHER_PUNCTUATION and Character.DASH_PUNCTUATION.

The above works fine except that I also have used DecimalFormat so that i can accept 8 decimal places. This logic fails when using a non-english locale such as German where a value like 12.34 is displayed as 12,34 which is rejected when I do a texfield.setText(). The textfield is set blank.

Can someone please suggest as to how should I go about so that value in textfield is not cleared when using German locales at same time I need to validate the enteries in the textfield?
 
Alice Corman
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try using NumberFormat with the desired locale?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic