2

Hello I'd like to use a mask for a JFormattedTextField this way:

MaskFormatter mask = new MaskFormatter("AA AAAA AAAA");
myField = new JFormattedTextField(mask);

but I want to be able to type variable number of characters, e.g.:

aa 11
4a 1125 4

etc.

Is there any simple way to do this, instead of extending maskformatter or writing my own class?

Thank u

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
myro
  • 1,158
  • 2
  • 25
  • 44
  • 3
    You could try a [Document Filter](http://docs.oracle.com/javase/tutorial/uiswing/components/generaltext.html#filter) – MadProgrammer Feb 13 '13 at 10:35
  • 2
    +1 to Mads comment See [this](http://stackoverflow.com/questions/14305921/detecting-jtextfield-deselect-event/14305952#14305952) answer with many other ways (including DocumentFilter) and their examples. – David Kroukamp Feb 13 '13 at 12:48

0 Answers0