JTextField limiting character amount input and accepting numeric only

前端 未结 7 1229

here\'s the code that i have on how to limit the character input length

class JTextFieldLimit extends PlainDocument {
  private int limit;
  // optional uppe         


        
7条回答
  •  余生分开走
    2020-11-28 00:13

    public static boolean validateInt(String txt) {
    
        String regx = "^[(0-9),;]+$";
        Pattern pattern = Pattern.compile(regx, Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(txt);
        boolean b = matcher.find();
        return b;
    
    }
    

提交回复
热议问题