Tag: 监听

带有监听器的JavaFX Textfield给出:“java.lang.IllegalArgumentException:start必须<= the end”

我得到一个例外,不明白是什么原因造成的。 这是一个FXML文件的FX应用程序。 在App的init()部分,我将一个监听器添加到一个文本字段,该文本字段调用一个函数,该函数使用模式的正则表达式监视String。 tf.textProperty().addListener( (observable, oldValue, newValue) -> { handleInput(newValue); }); function: private void handleInput(String s) { s = s.toUpperCase(); Matcher matcher = Pattern .compile( “^[AZ]{2}(20|21|22|23|[0-1]\\d)[0-5]\\d(20|21|22|23|[0-1]\\d)[0-5]\\d(T\\s|C\\s|TC|CT|\\s\\s)$”) .matcher(s); if (matcher.find()) { // do something // then clear the textfield tf.clear(); } else { // do something else } } 它有效,但在匹配匹配的情况下给我一个例外。 例外: Exception in thread “JavaFX Application […]