I need to restrict the size as well as check the Input characters entered in the JFormattedTextField.
I know that to restrict the size I can use
t1= new JFormattedTextField(new MaskFormatter("*****"));

For checking the characters entered in the Field, here is the class.
class FilteredFormatter extends DefaultFormatter {
protected DocumentFilter getDocumentFilter() {
return new InputFilter();
}
}

class InputFilter extends DocumentFilter {


String domain = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.";

public void insertString(DocumentFilter.FilterBypass fb,
int offset,
String str,
AttributeSet attr) throws BadLocationException
{

replace(fb, offset, 0, str, attr);
}

public void replace(DocumentFilter.FilterBypass fb,
int offset,
int length,
String str,
AttributeSet attrs) throws BadLocationException {
char[] source = str.toLowerCase().toCharArray();
char[] result = new char[source.length];
int j = 0;

for(int i = 0; i < result.length; i++)
if(domain.indexOf(source[i]) != -1)
result[j++] = source[i];

fb.replace(offset, length, new String(result, 0, j), attrs);
}
}

I can do that by creating the new Instance
t1= new JFormattedTextField(new FilteredFormatter());

I want both size and charvalidation. With this only one is possible at a time. How do I get both with the above code?