Como faço para criar uma maskara em formato de data no JTextField
Ex: //__
O JTextField não possui nenhummétodo pronto para isto, apenas o JFormattedTextField possui algo assim.
Veja exemplos neste site:
http://www.exampledepot.com/egs/javax.swing.text/pkg.html?l=rel#JFormattedTextField
http://java.sun.com/j2se/1.5.0/docs/api/
troque o textfild por um formattedtextfild e depois instale uma máscara nele.
boa sorte.
no JFormattedFieldText
MaskFormatter maskdatarec;
try {
maskdatarec= new MaskFormatter("##/##/####");
maskdatarec.setValidCharacters("0123456789");
maskdatarec.install(DATA_RECAD);
} catch(Exception ex) {
ex.printStackTrace();
}
DATA_RECAD.updateUI();