Code example for DefaultFormatterFactory

0
        } 
 
        //textField.setFormatterFactory(new DefaultFormatterFactory(dateFormatter)); 
        if (inputMask != null) {
            inputMask.setAllowsInvalid(true);
            textField.setFormatterFactory(new DefaultFormatterFactory(inputMask));
        } 
 
        // set initial value to lowest possible date. 
        //textField.setValue(nv.getVal1()); 
        textField.setFocusLostBehavior(JFormattedTextField.PERSIST);
 
        textField.getInputMap()
                .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "validate");
        textField.getActionMap().put("validate",
                new AbstractAction() {
                    public void actionPerformed(ActionEvent e) {
                        if (!textField.isEditValid()) { //The text is invalid.
                            textField.postActionEvent();
                        } else {