开发者

How to restrict JTextField not taking more than 'x' numbers of inputs

开发者 https://www.devze.com 2023-02-16 14:42 出处:网络
I have a开发者_如何学Python 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.

I have a开发者_如何学Python 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?


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.

0

精彩评论

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

关注公众号