Possible Duplicate:
Limiting and formatting a JTextfield
I have a JTextfield where a user enters a "social security number". The SSN has 9 digits and 2 dashes for a total of 11 characters.
How do I limit the JTextField to 11 characters and also have 2 dashes in the textfield at the 4th and 7th position of the 11 characters?
one thought, i have is using an IF statement stating that the soc(which would be the input to the Jtextfield) has to be greater than or equal 000000001 and less than or equal to 999999999 then once that is determined. could i use a substring to for positions 0-2 assign that to varible than concatenate that with a "-" then create another subsstring for positions 3-4 and concatenate that with the prior varibles and add the last "-" and then finish the input.
is that possible? does that make logical sense?