Creating a Text Field to Display and Edit a social security number
import javax.swing.JFormattedTextField; import javax.swing.text.MaskFormatter; public class Main { public static void main(String[] argv) throws Exception{ MaskFormatter fmt = new MaskFormatter("###-###-####"); JFormattedTextField tft1 = new JFormattedTextField(fmt); fmt = new MaskFormatter("###-##-####"); JFormattedTextField tft2 = new JFormattedTextField(fmt); } }