Special mask for JFormattedTextField


2003-08-07 03:49:02 PM
jbuilder20
Hi,
I got a problem to create a special mask for a JFormattedTextField. I
got the follwing code:
mask = new MaskFormatter();
mask.setValidCharacters("0123456789.");
try
{
mask.setMask("???#");
}
catch (ParseException ex1)
{
}
component = new JFormattedTextField(mask);
But this is not how it should work. I want to build in the following
restriction for the characters:
* Maximum of characters is 4
* First character must be a digit or a dot
* Second character must be a digit if the first character is a dot.
Otherwise it may be a digit or a dot.
* Third character must be a digit if the second character is a dot.
Otherwise it may be a digit or a dot.
* Forth character must be a digit
* When a dot is used, there may only be one character putted in after
it and must be a 5
* The value in this JFormattedTextField may variate from empty to
9999, which means that the value can contain 1, 2, 3 or 4 characters.
Is it possible to set restrictions for just one charcater, so that I
can build in above mentioned restrictions?
I hope someone can help me out here,
thnx in advance
Rogier