Colocar máscara em textfield

Olá, gostaria de saber como colocar máscara em um campo que receberá data, rg e cpf. ex: data: dd/mm/aaaa
rg: xx.xxx.xxx-x
cpf: xxx.xxx.xxx-xx

exemplo vê se isso ajuda flou!

[code]
lblDataNasc1.setText(“Data”);

    try {
        txtDataExpedicao.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
    } catch (java.text.ParseException ex) {
        ex.printStackTrace();
    }
    txtDataExpedicao.setFocusLostBehavior(javax.swing.JFormattedTextField.PERSIST);
    txtDataExpedicao.setName("data"); [/code]

[color=red]cpf:[/color]

[code]
lblCPF.setText(“CPF”);

    try{
        txtCPF.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###.###.###-##")));
    } catch (java.text.ParseException ex) {
        ex.printStackTrace();
    }
    txtCPF.setFocusLostBehavior(javax.swing.JFormattedTextField.PERSIST);
    txtCPF.setName("cpf"); 
    txtCPF.setHorizontalAlignment(javax.swing.JTextField.RIGHT);[/code]

Olhe:
http://java.sun.com/docs/books/tutorial/uiswing/components/formattedtextfield.html

Observe tmb os caracteres usados pra máscaras:

- Números

U - Qlqr caracter, passando td pra maiusculo
L - Qlqr caracter, passando td pra minusculo
A - Caracter e número

    • Qlqr coisa…

pra + detelhes:
http://www.java2s.com/Tutorial/Java/0240__Swing/0320__JFormattedTextField.htm
:!:

Vou fazer os testes aqui, e já retornarei a resposta. Obrigado.