(JFormattedTextField) To mais confuso que tudo e com dor de cabeça

Meu problema é o seguinte:

Por Exemplo

Tenho o Mascara Telefone.


try{
JFormattedTextFieldtelefone = new javax.swing.JFormattedTextField(new MaskFormatter("(##)####-####"));
} catch (Exception ex){
    JOptionPane.showMessageDialog(null, "Erro no campo Telefone");
}

Isto esta em uma Jframe de cadastro, Porem apos fazer o 1° cadastro OK.

Se por algum motivo eu clicar no campo e não preencher ele se completa com o dado anterior.
Se apago o que está la dentro e deixo em branco quando aperto TAB ou clico no próximo campo ele se completa novamente com o valor anterior.

Já tentei procurar na Net, porem PARECE que nestes casos é melhor usar JForms, porem não sei como encontrar nem como usar.
Eu consegui adicionar aos Plugins pelo NetBeans porem não achei nenhum componente JForms na paleta de ferramentas.

Alguém sabe alguma forma de resolver este problema com a mascara.

Oi,

Use o método setFocusLostBehavior(int).

Segue documentação:

[quote]JFormattedTextField.REVERT
Revert the display to match that of getValue, possibly losing the current edit.

JFormattedTextField.COMMIT
Commits the current value. If the value being edited isn’t considered a legal value by the AbstractFormatter that is, a ParseException is thrown, then the value will not change, and then edited value will persist.

JFormattedTextField.COMMIT_OR_REVERT
Similar to COMMIT, but if the value isn’t legal, behave like REVERT.

JFormattedTextField.PERSIST
Do nothing, don’t obtain a new AbstractFormatter, and don’t update the value.

The default is JFormattedTextField.COMMIT_OR_REVERT, refer to setFocusLostBehavior(int) for more information on this.[/quote]

Sugiro a utilização de:

Tchauzin!

1° Eu estava utilizando o campo errado.

Estava utilizando JTextField e instanciando JFormattedTextField.
Desta forma não conseguia usar:

seuField.setFocusLostBehavior(JFormattedTextField.PERSIST);  

Nossa Hávia pesquisado isto há mais de uma semana e consegui as repostas certas AQUI.

Muito Obrigado a todos que ajudaram.

Att,

Eduardo F.