Some questions about JFormattedTextField

P

Paul Tomblin

I've been working my google fingers to the bone over this one, as well as
writing lots of experimental code.

In Java 1.4 JFormattedTextField:

1. Why doesn't the date formatter act like MaskFormatter and automatically
put the separator character as you type? Is there a way to change that?

I'm getting the date formatter using
dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
DateFormatter df = new DateFormatter(dateFormat)
JTextField startDate = new JFormattedTextField(df);

2. Is there a good way to input HH:MM:SS durations rather than dates? I'm
using a MaskFormatter, but of course it doesn't stop you from entering
from entering a duration of 55:66:77. I suppose I could use an
InputVerifier? I though about using a DocumentListener but I don't see
any way to refuse to take input if they enter a digit greater than 5 in
the 4 or 6th positions.

3. Going back to DateFormatter again, is there a way to make it stop
taking invalid dates? I can put 99/99/2005 into one and it returns a date
of 6/7/2013. I'd rather it refused to take it, preferably interactively
rather than waiting for the focus lost event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top