如何偵測TextField資料變動(應適用其他元件)

/*偵測<文字框>單價的狀況,當變動時啟動偵測機制來檢查金額差距*/
textPrice.textProperty().addListener((observable, oldValue, newValue) -> {
System.out.println(“textfield changed from ” + oldValue + ” to ” + newValue);

Check_Order_Workers_Price();

});

當使用JavaFX的TextField時如何限制使用者輸入的字數

/*限制帳號長度*/
tf_account_number.textProperty().addListener((observable, oldValue, newValue)->{
System.out.println(“tf_account_number運作中”);
if(newValue.length()>14){
tf_account_number.setText(oldValue);
}
});

 

發佈留言

Your email address will not be published. Required fields are marked *