我想限制no。可以放在JTextField
上的字符,因爲在我的數據庫中,我有這個列有Sex,Status(允許的字符數只有1)。java應用。字符串操作
和中間初始值(其中允許的字符數僅爲2)。
這是我在我的腦海:
(性別,狀態欄)
String text = jTextField2.getText();
int count = text.();
if (count>1) {
(delete the next character that will be input)
}
(用於M.I.列)
String text = jTextField1.getText();
int count = text.();
if (count>2) {
(delete the next character that will be input)
}
這可能嗎?有沒有一個命令會刪除下一個字符,所以沒有。的字符。我的數據庫可以接受嗎?
對不起,我把「==」而不是「>」,我的壞。 – 2013-04-10 02:57:46