Java examples for Swing:JFormattedTextField
Have a field to format a date in mm/dd/yyyy format
import java.text.DateFormat; import java.text.SimpleDateFormat; import javax.swing.JFormattedTextField; import javax.swing.text.DateFormatter; public class Main { public static void main(String[] args) { DateFormat dateFormat = new SimpleDateFormat("mm/dd/yyyy"); DateFormatter dateFormatter = new DateFormatter(dateFormat); JFormattedTextField dobField = new JFormattedTextField(); dobField = new JFormattedTextField(dateFormatter); }/* w ww .ja v a2s. c om*/ }