JFormattedTextField formatting problems

Hi All

Forgive me if this has been answered before as I could find no solution.

My problem is that I want to provide a formatted to allow the user enter some data. But the format can be one of two variations depending on what the fourth character is.

For example Valid text can be AA9 9AA or AA12 2AA. Basically the same format as a postcode. All I want to do is to make sure that the letters are all in uppercase.

I have tried various things with MaskFormatter and trying to change the mask after the fourth character has been entered, but with no luck.

Any pointers would be great.

Thanks

David

[646 byte] By [david.beera] at [2007-10-3 4:18:22]
# 1
Maybe there's a shortcut, but as a first attempt I'd implement a subclass of PlainDocument which when changed validates itself against a Regex for the postcode format (which is fairly straightforward) and changes the content to all upper case.
itchyscratchya at 2007-7-14 22:20:03 > top of Java-index,Desktop,Core GUI APIs...
# 2
Would this also check as the user types. I don't really wont the change after they have finished.I am quite new to the text area of swing is there any chance of a small example.David
david.beera at 2007-7-14 22:20:03 > top of Java-index,Desktop,Core GUI APIs...
# 3
Don't think this can be done with JFormmatedTextField.I would try using a [url http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#filter]Document Filter[/url]. The filter is invoked as the user types.
camickra at 2007-7-14 22:20:03 > top of Java-index,Desktop,Core GUI APIs...
# 4
Thanks for the link. So if I was to make all the text ALL CAPS which constant would I use. I can't seem to find a constant for this.
david.beera at 2007-7-14 22:20:03 > top of Java-index,Desktop,Core GUI APIs...
# 5
String.toUpperCase();
camickra at 2007-7-14 22:20:03 > top of Java-index,Desktop,Core GUI APIs...
# 6
Hi camickr Thanks for the reply, I found the answer and an exa,ple just after I posted the question. Any way thanks for the hint problem solved.I will give you the duke dolars.
david.beera at 2007-7-14 22:20:03 > top of Java-index,Desktop,Core GUI APIs...