3

How can I limit the keyboard input before it will be entered into JTextField (swing)

I want to allow user to input only "+-0123456789abcdef,." chars, and no more than 1 , or . char

My JTextField is one-line input field.

thanks!

osgx
  • 90,338
  • 53
  • 357
  • 513

1 Answers1

4

You can achieve this by DocumentFilter. This allows you to control text handling for any Document type. Or use a JFormattedTextField

ring bearer
  • 20,383
  • 7
  • 59
  • 72