I'm doing a program and it uses some formatted JTextFields, that is, JFormatedTextField that calls a MaskFormatter. The problem is that when writing a message and trying to delete it, the message comes back, making it impossible to leave the field empty again. Does anyone have a solution for this? Here is the code I'm using:
package main;
import javax.swing.JTextField;
import javax.swing.text.MaskFormatter;
public class NewScheduleWindow extends JFrame{
JTextField hourField = new JTextField();
public NewScheduleWindow(){
try {
hourField = new JFormattedTextField(new MaskFormatter("##:##"));
} catch (ParseException e) {
e.printStackTrace();
}
add(hourField);
hourField.setBounds(160, 65, 42, 25);
hourField.setFont(Reference.setDefaultFont(15));
hourField.requestFocus();
//Etc...