A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Android Security Essentials Live Lessons
this week in the
Swing / AWT / SWT
Use mask formatter in conjunction with a DateFormatter in Swing
Theodore David Williams
Joined: Dec 21, 2009
Feb 11, 2010 10:11:28
I have a date field in a swing gui and the user would like not to have to enter the '/' 's between the date and the ':' ' s between the time.
If I use a
with a date formatter i.e.
JFormattedTextField formattedText = new JFormattedTextField(new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"));
Then I have the ability to format date correctly but I have to enter the "/' 's and the ":" 's maunally
If I use a FormattedTextField with a
JFormattedTextField formattedText = new JFormattedTextField(new MaskFormatter("##/##/#### ##:##:##"));
Now the user will not have to enter /'s or :'s but I imagine that I lose some of what the date formatter will give me right?
It is sorta covered in the
JavaRanch Style Guide
subject: Use mask formatter in conjunction with a DateFormatter in Swing
Strange behavior of the JFormattedTextField
urlyBird 1.2.3 - customer holding record
MaskFormatter in JTable
JFormatField + MaskFormatter + AnnoyingFeature!!
setting limited number of characters for a text field
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014