views:

235

answers:

2

I have people entering alot of ammounts in form, so pressing one key less is what will count on huge ammounts of data.

Idea is not to press decimal separator when entering currency ammount. I need some subclass of JTextField which will automatically show decimal and thousand separators while entering number. Is out there something already developed for instant use? Found nothing on google..

thx

+1  A: 

You can use a JFormattedTextField http://java.sun.com/docs/books/tutorial/uiswing/components/formattedtextfield.html,

Jeff Storey
yes... still no option for MaskFormatter to be hardcoded into text input area so user can't change it, only see it and browse around like it is JLabel, for instance..
ante.sabo
You could override the setFormatter method so it doesn't actually change anything (after you set it once), or you could create a wrapper around JTextField that delegates all of its method calls to the underlying JTextField but doesn't have a setter method.
Jeff Storey
+1  A: 

You can set an InputVerifier that can enforce any rules you want. This example shows a simple currency format and a data/time verifier that accepts multiple formats. You can adapt it to accept the default format and interpret a missing decimal separator as a value in cents.

trashgod