Here you can find the source of dateCompleteOnlyFormat(JTextField pJTextField, KeyEvent e)
public static void dateCompleteOnlyFormat(JTextField pJTextField, KeyEvent e)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import java.awt.event.KeyEvent; public class Main { public static void dateCompleteOnlyFormat(JTextField pJTextField, KeyEvent e) {/*from www.j av a 2 s .c o m*/ char keyChar = e.getKeyChar(); if (Character.isDigit(keyChar)) { if ((pJTextField.getText().trim().length() == 2) || (pJTextField.getText().trim().length() == 5)) pJTextField.setText(pJTextField.getText().trim() + "/"); } } }