MaskFormatter fmt = null; // A phone number try { fmt = new MaskFormatter("###-###-####"); } catch (java.text.ParseException e) { } JFormattedTextField tft1 = new JFormattedTextField(fmt); // A social security number try { fmt = new MaskFormatter("###-##-####"); } catch (java.text.ParseException e) { } JFormattedTextField tft2 = new JFormattedTextField(fmt);