2

I need JFormattedTextField which will format date ("dd.MM.yy"). Code:

SimpleDateFormat format= new SimpleDateFormat("dd.MM.yy");
DateFormatter formatter = new DateFormatter(format);
format.setLenient(false);
formatter.setAllowsInvalid(false);
formatter.setOverwriteMode(true);
JForemattedTextField inputText = new JFormattedTextField(formatter);
inputText.setValue(new Date());

The problem is: if the date is "11/06/12" for example and if I try to input 12 on month I can't do it because when I type 1 it understands the month as 16 and doesn't give me to input the next digit. I need that when I type for example 12 on month position then the JFormattedTextField will check the correctness of the month only after I typed the second digit, and if it is incorrect the month will return back to previous value. How can I solve this?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
abg
  • 2,002
  • 7
  • 39
  • 63

1 Answers1

2
Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319