开发者

Filter the user's keyboard input into JTextField (swing)

开发者 https://www.devze.com 2023-02-04 10:21 出处:网络
How can I limit the keyboard input before it will be entered into JTextField (swing) I want to allow user to input only

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!


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

0

精彩评论

暂无评论...
验证码 换一张
取 消