How do you replace pre-entered characters (one at a time) in the JTextField?

78 Views Asked by At

I am trying to create a text field that at first contains only underscores and dashes, in which the user will enter numbers, for entering social security numbers. Every time the user enters a character, the underscore in the string will be replaced with that number, for example, ___-__-____ then xxx-__-____, xxx-xx-____, but the dashes will not be replaced, instead skipped over.I'm really stuck on this, and any help at all is appreciated.

1

There are 1 best solutions below

0
On

Use JFormattedTextField. For details go through this tutorial.