Filter user keyboard input in JTextField (swing)

How can I limit keyboard input before it is entered in JTextField (swing)

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

My JTextField is a single line input field.

thank!

+3
source share
1 answer

You can achieve this DocumentFilter . This allows you to control text processing for any type of document. Or use JFormattedTextField

+4
source

Source: https://habr.com/ru/post/1785277/


All Articles