• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NumberFormat, Currency, JTextField

 
Thomas Mcfarrow
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I want to make a JTextField that will take input in and format it accordingly to the current locale's currency. The key here is that programmatically I need to detect what locales have decimal points.

Additionally, I need the number input to start from the right.

Furthermore, I have a somewhat working model for US currency but I would like to make it generic enough for global use.

For example (US Dollar):

User Enters 2 --> JTextField shows $0.02
User Enters 3 --> JTextField shows $0.23
User Enters 4 --> JTextField shows $2.34
User Enters 5 --> JTextField shows $23.45
User Enters 6 --> JTextField shows $234.56

Thanks
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the class DecimalFormatSymbols. You might also want to take a look at JFormattedTextField.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic