0

I have a JTextField. That takes in strings. For one JTextField, I want to limit to only two strings. For example 'fa' or '56' or '..' Not more than two.

Is there a way to do this?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
razshan
  • 1,128
  • 12
  • 41
  • 59

1 Answers1

3

You can use a Formatted Text Field.

Or you can create a custom Document Filter.

Creating a custom Document is an old approach that is generally not used anymore.

camickr
  • 321,443
  • 19
  • 166
  • 288