我想限制没有。可以放入的字符,JTextField
因为在我的数据库中,我有这个具有 Sex,Status 的列(允许的字符数仅为 1)。
和中间首字母(允许的字符数仅为 2)。
这就是我的想法:
(对于性别,状态列)
String text = jTextField2.getText();
int count = text.();
if (count>1) {
(delete the next character that will be input)
}
(对于 MI 列)
String text = jTextField1.getText();
int count = text.();
if (count>2) {
(delete the next character that will be input)
}
这可能吗?有没有删除下一个字符的命令,所以没有。的字符。我的数据库可以接受吗?