/** * @param title Title, message * @param correct_password Password to check */ public PasswordDialog(final String title, final String correct_password) { this.correct_password = correct_password; final DialogPane pane = getDialogPane(); pass_entry.setPromptText(Messages.Password_Prompt); pass_entry.setMaxWidth(Double.MAX_VALUE); getDialogPane().setContent(pass_entry); setTitle(Messages.Password); setHeaderText(title); pane.getStyleClass().add("text-input-dialog"); pane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); // Check password in dialog? if (correct_password != null && correct_password.length() > 0) { final Button okButton = (Button) pane.lookupButton(ButtonType.OK); okButton.addEventFilter( ActionEvent.ACTION, event -> { if (!checkPassword()) event.consume(); }); } setResultConverter( (button) -> { return button.getButtonData() == ButtonData.OK_DONE ? pass_entry.getText() : null; }); Platform.runLater(() -> pass_entry.requestFocus()); }
private boolean checkPassword() { final String password = pass_entry.getText(); if (correct_password.equals(password)) return true; setHeaderText(Messages.Password_Error); Platform.runLater(() -> pass_entry.requestFocus()); return false; }
@FXML private void giris(ActionEvent event) throws IOException { Boolean durum = false; try { String sAdminAdi = kuladi.getText(); String sAdminSifre = sifreleme(sifre.getText()); if (sAdminAdi.equals("")) { Alert alert = new Alert(Alert.AlertType.WARNING, "Lütfen Kullanıcı Adını Giriniz.", ButtonType.OK); alert.setHeaderText(null); alert.setTitle("Uyarı"); alert.showAndWait(); kuladi.requestFocus(); sifre.setText(""); durum = true; } else if (sifre.getText().equals("")) { Alert alert = new Alert(Alert.AlertType.WARNING, "Lütfen Şifreyi Giriniz.", ButtonType.OK); alert.setHeaderText(null); alert.setTitle("Uyarı"); alert.showAndWait(); sifre.requestFocus(); durum = true; } else { SessionFactory sf = new org.hibernate.cfg.Configuration().configure().buildSessionFactory(); Session sess = sf.openSession(); Transaction ts = sess.beginTransaction(); Query qee = sess.createQuery("from SuperAdmin"); Iterator ite = qee.iterate(); while (ite.hasNext()) { SuperAdmin obj = (SuperAdmin) ite.next(); String kuladi = obj.getKulAdi(); String sifre = obj.getSifre(); if (sAdminAdi.equals(kuladi) & sAdminSifre.equals(sifre)) { Integer sID = obj.getSuperID(); // label.setText(sID.toString()); Parent root = null; Stage stage = new Stage(); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("yonlendir.fxml")); root = fxmlLoader.load(); yonlendirController cont = fxmlLoader.getController(); cont.getRefCode(sID); stage.setScene(new Scene(root)); stage.show(); durum = true; } } if (durum == false) { Alert alert = new Alert(Alert.AlertType.WARNING, "Hatalı Kullanıcı Adı veya Şifre", ButtonType.OK); alert.setHeaderText(null); alert.setTitle("Uyarı"); alert.showAndWait(); kuladi.setText(""); sifre.setText(""); kuladi.requestFocus(); } ts.commit(); sess.close(); } } catch (HibernateException he) { System.out.println(he); } }