Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javafx 是否存在事件,例如检测文本字段何时失去焦点?_Javafx - Fatal编程技术网

Javafx 是否存在事件,例如检测文本字段何时失去焦点?

Javafx 是否存在事件,例如检测文本字段何时失去焦点?,javafx,Javafx,我正试图找到一种解决方案来检测TextField何时失去焦点。 这是我目前掌握的一些代码 是否存在类似于KeyEvent的事件,或者我需要使用其他方法 private void buildGui() { setVgap(10); setHgap(10); setPadding(new Insets(50)); Label lblgb = new Label("Gebruikersnaam:"); Label lblww1 = new Label("Wa

我正试图找到一种解决方案来检测
TextField
何时失去焦点。 这是我目前掌握的一些代码

是否存在类似于
KeyEvent
的事件,或者我需要使用其他方法

private void buildGui() {

    setVgap(10);
    setHgap(10);
    setPadding(new Insets(50));

    Label lblgb = new Label("Gebruikersnaam:");
    Label lblww1 = new Label("Wachtwoord:");
    Label lblww2 = new Label("Bevestig wachtwoord:");

    txfGebruikersnaam = new TextField();
    txfWachtwoord = new TextField();
    txfWachtwoord2 = new TextField();

    txfGebruikersnaam.setOnMouseExited(new javafx.event.EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            String gebr = txfGebruikersnaam.getText().trim();

            if (gebr.matches("\\s")) {
                String[] strSplit = gebr.split(" ");
                String a = strSplit[0];
                String b = strSplit[1];

                if (a.length() >= 4 && b.length() >= 8) {
                    if (!(Character.isUpperCase(a.charAt(0)) && Character.isDigit(b.charAt(b.length() - 1)))) {
                        errorAlerts("Het eerste woord moet beginnen met een hoofdletter, het 2e moet eindigen met een cijfer!");
                    }
                } else {
                    errorAlerts("Het eerste woord moet minstens 4 letters lang zijn, het 2e minstens 8!");
                }
            } else {
                errorAlerts("Uw gebruikersnaam moet uit 2 woorden bestaan!");
            }
        }
    });
private void buildGui(){
setVgap(10);
setHgap(10);
设置填充(新插图(50));
标签lblgb=新标签(“Gebruikersnaam:”);
标签lblww1=新标签(“Wachtwoord:”);
标签lblww2=新标签(“Beverstig wachtwoord:”);
txfGebruikersnaam=新文本字段();
txfWachtwoord=新文本字段();
txfWachtwoord2=新文本字段();
txfGebruikersnaam.setOnMouseExited(新的javafx.event.EventHandler(){
@凌驾
公共无效句柄(MouseeEvent事件){
字符串gebr=txfGebruikersnaam.getText().trim();
如果(gebr.匹配(“\\s”)){
字符串[]strSplit=gebr.split(“”);
字符串a=strSplit[0];
字符串b=strSplit[1];
如果(a.length()>=4和&b.length()>=8){
if(!(Character.isUpperCase(a.charAt(0))&Character.isDigit(b.charAt(b.length()-1))){
错误警报(“他是埃斯特·伍德·莫特·贝金南遇到了胡夫德莱克,他是埃因迪根遇到了西弗!”);
}
}否则{
错误警报(“Het eerste woord moet minstens 4个字母lang zijn,Het 2e minstens 8!”);
}
}否则{
错误警报(“Uw gebruikersnaam moet uit 2 woorden bestaan!”);
}
}
});

可能存在的重复项有一个
节点.聚焦
属性和一个
场景.聚焦所有者
属性。此外,当
文本字段
失去焦点时,会应用一个
文本格式化程序
的转换器。谢谢你的评论,我会研究它