今私はすべての入力フィールドをチェックするのに苦労しています== ""
。JavaFXのSqliteでTextFieldが空になっています
私はここで多くの解決策を見つけましたが、どういうわけかそれは働きません。
私はRegistrationModalとRegistrationControllerを持っています。モーダルで
は、私はそのようなフィールドをチェックするためにしようと試み:
public boolean RegisterUser(String user, String vorname, String nachname) throws SQLException {
PreparedStatement preparedStatement = null;
if (user == "" || vorname == "" || nachname == "") {
System.out.println("Fill in all fields");
return false;
}
// Here follows the SQL query the prepared statement and exequte
}
をしかし、if文、それはそれは、これを使用することはありません、私がなぜ分かりませんか?
私はまた、コントローラに空の要素をキャッチするためにしようと試み:
ここpublic void Absenden(ActionEvent event) {
try {
if (registerModel.RegisterUser(txt_user.getText(), txt_vorname.getText(),
txt_nachname.getText())) {
if (registerModel.RegisterUser(txt_user.getText().trim().isEmpty(), txt_vorname.getText().trim().isEmpty(),
txt_nachname.getText().trim().isEmpty())) {
System.out.println("False! Do something?");
}
// Here opens the new window with a notification Registration was successfull
((Node) event.getSource()).getScene().getWindow().hide();
}
なぜ2すでに奇妙なようだif文、私はこれを行うために、モデル内の新しい方法を自動生成していたthatsのように、私はエラーを持っていましたブーリアンで動作しますが、依然としてこのif文を使用したことはありません。
関連するコードのみを提供しようとしました。それ以外の場合は、はるかに多くなります。
多分誰かが考えを持っています。
ありがとうございました
tr ==の代わりにequalsを使ってickしても、私は仕事を続けることができます、ありがとうございます。 5分で受け入れます。 – Roman