mardi 23 juin 2015

How can I set pattern value on JFormattedTextField?

How can I set one pattern value from XSD schema example:

<xsd:pattern value="[A-Za-z]{6}" />

on JFormattedTextField? Something as this:

private JFormattedTextField text1_1
text1_1 = new JFormattedTextField(createFormatter("##U"));


 protected static MaskFormatter createFormatter(String s) {
    MaskFormatter formatter = null;
    try {
        formatter = new MaskFormatter(s);
    } catch (java.text.ParseException exc) {
        System.err.println("formatter is bad: " + exc.getMessage());
        System.exit(-1);
    }
    return formatter;
}

Something as that:

text1_1 = new JFormattedTextField(createFormatter("[A-Za-z]{6}"));

THX

Aucun commentaire:

Enregistrer un commentaire