We can use the following constructor to create JFormattedTextField.
constructor:public JFormattedTextField() usage :JFormattedTextField formattedField = new JFormattedTextField(); constructor:public JFormattedTextField(Format format) usage :DateFormat format = new SimpleDateFormat("yyyy--MMMM--dd"); JFormattedTextField formattedField = new JFormattedTextField(format); constructor:public JFormattedTextField(JFormattedTextField.AbstractFormatter formatter) usage :DateFormat displayFormat = new SimpleDateFormat("yyyy--MMMM--dd"); DateFormatter displayFormatter = new DateFormatter(displayFormat); JFormattedTextField formattedField = new JFormattedTextField(displayFormatter); constructor:public JFormattedTextField(JFormattedTextField.AbstractFormatterFactory factory) usage :DateFormat displayFormat = new SimpleDateFormat("yyyy--MMMM--dd"); DateFormatter displayFormatter = new DateFormatter(displayFormat); DateFormat editFormat = new SimpleDateFormat("MM/dd/yy"); DateFormatter editFormatter = new DateFormatter(editFormat); DefaultFormatterFactory factory = new DefaultFormatterFactory( displayFormatter, displayFormatter, editFormatter); JFormattedTextField formattedField = new JFormattedTextField(factory); constructor:public JFormattedTextField(JFormattedTextField.AbstractFormatterFactory factory, Object currentValue) usage :DateFormat displayFormat = new SimpleDateFormat("yyyy--MMMM--dd"); DateFormatter displayFormatter = new DateFormatter(displayFormat); DateFormat editFormat = new SimpleDateFormat("MM/dd/yy"); DateFormatter editFormatter = new DateFormatter(editFormat); DefaultFormatterFactory factory = new DefaultFormatterFactory( displayFormatter, displayFormatter, editFormatter); JFormattedTextField formattedField = new JFormattedTextField(factory, new Date()); constructor:public JFormattedTextField(Object value) usage :JFormattedTextField formattedField = new JFormattedTextField(new Date());