como adicionar esse metodo no JTextField???
[code] import javax.swing.JOptionPane;
import javax.swing.text.MaskFormatter;
public class Mascara {
private MaskFormatter cpf = new MaskFormatter();
public MaskFormatter getCpf(){
try{
this.cpf.setMask("###.###.###-##");
this.cpf.setValidCharacters("0123456789");
} catch (Exception e){
JOptionPane.showMessageDialog(null,
"Erro ao criar uma m�scara",
"Mensagem do Sistema",
JOptionPane.ERROR_MESSAGE);
}
return this.cpf;
}
}
[/code]
como colocá-la aqui???
ou chamá-la aqui???
[code]public RotuloClientes()
{
// Painel de Rótulo
labelPanel = new JPanel();
labelPanel.setLayout(new GridLayout ( labels.length,1 ) );
for ( int i = 0; i < labels.length; i++ )
labelPanel.add( new JLabel( labels[ i ], 0) );
// Painel de TextField
fieldsPanel = new JPanel();
fieldsPanel.setLayout(new GridLayout( labels.length, 1 ) );
cod = new JTextField( 20 );
cod.setEditable( false );
fieldsPanel.add( cod );
cod.setFont(new Font("Arial", Font.BOLD,24));
cod.setForeground(Color.red);
cpf = new JTextField( 9 );
fieldsPanel.add(cpf);
primeironome = new JTextField( 20 );
fieldsPanel.add( primeironome );[/code]