/* /Check of de naam in de database gelijk is aan de textveld tfBeginUsername */ @FXML public void Login() throws IOException, SQLException, NotBoundException { try { // check if the user is already online. for (User usr : loginIn.getOnlineUsers()) { if (usr.getName().equals(tfBeginUsername.getText())) { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Information"); alert.setHeaderText(null); alert.setContentText("User is already online"); alert.showAndWait(); } else if (loginIn.Login(tfBeginUsername.getText(), tfBeginPassword.getText()) != null) { user = loginIn.Login(tfBeginUsername.getText(), tfBeginPassword.getText()); LobbySession.user = user; userName = user.getName(); LbLobbyUserName.textProperty().bind(userNameProperty); loginIn.addToOnline(LobbySession.user); stage = (Stage) btBeginLogIn.getScene().getWindow(); root = FXMLLoader.load(getClass().getResource("Lobby.fxml")); Scene scene = new Scene(root); scene.getStylesheets().add((new File("css/Lobby.css")).toURI().toURL().toExternalForm()); stage.setScene(scene); stage.setResizable(false); stage.show(); } else { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Information"); alert.setHeaderText(null); alert.setContentText("Please enter correct name and password"); alert.showAndWait(); } } if (loginIn.getOnlineUsers().isEmpty()) { user = loginIn.Login(tfBeginUsername.getText(), tfBeginPassword.getText()); LobbySession.user = user; userName = user.getName(); LbLobbyUserName.textProperty().bind(userNameProperty); loginIn.addToOnline(LobbySession.user); stage = (Stage) btBeginLogIn.getScene().getWindow(); root = FXMLLoader.load(getClass().getResource("Lobby.fxml")); Scene scene = new Scene(root); scene.getStylesheets().add((new File("css/Lobby.css")).toURI().toURL().toExternalForm()); stage.setScene(scene); stage.setResizable(false); stage.show(); } } catch (Exception ex) { System.out.println("Not working: " + ex); } }
private void selectDestFolder() { ListItem item = destDirectoryListView.getSelectionModel().getSelectedItem(); Alert confirm = new Alert(AlertType.CONFIRMATION); confirm.setTitle("ファイル移動"); confirm.setHeaderText(item.folder.getDestPath() + " に移動します。"); confirm.setOnCloseRequest( e -> { if (confirm.getResult() == ButtonType.OK) { try { item.folder.moveInto(this.targetFiles); Alert complete = new Alert(AlertType.INFORMATION); complete.setTitle("移動完了"); complete.setHeaderText(this.targetFiles.size() + " 件のファイルを移動しました。"); complete.setContentText("移動先:" + item.folder.getDestPath()); complete.show(); this.clear(); } catch (UncheckedIOException ex) { Alert error = new Alert(AlertType.ERROR); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); ex.printStackTrace(pw); TextArea textArea = new TextArea(sw.toString()); error.getDialogPane().setExpandableContent(textArea); error.setContentText("ファイル保存中にエラーが発生しました。"); error.show(); } } }); confirm.show(); }
// @Override // public void setScreenParent(ScreensController screenParent) { // controller = screenParent; // } @FXML public void buttonClick(ActionEvent event) throws IOException { // controller.loadScreen(Main.createAdminFile); if (checkInfo()) { Alert emptyInfo = new Alert(Alert.AlertType.ERROR); emptyInfo.setTitle("Error"); emptyInfo.setHeaderText("Please make sure to correctly fill out the following: \n"); emptyInfo.setContentText(errorStr); emptyInfo.showAndWait(); } else { groupDir = Paths.get("").toAbsolutePath().toString() + "\\" + groupUsernameField.getText(); if (!Files.exists(Paths.get(groupDir))) { saveData(); Stage stage = (Stage) groupNext.getScene().getWindow(); Parent root = FXMLLoader.load(getClass().getResource(Main.createAdminFile)); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); } else { Alert emptyInfo = new Alert(Alert.AlertType.ERROR); emptyInfo.setTitle("Error: Company exists"); emptyInfo.setHeaderText(null); emptyInfo.setContentText( "Company by that name already exists in the system. Please enter a new company name."); emptyInfo.showAndWait(); } // Files.delete(file.toPath()); } }
public boolean saveGame(String saveName, int index) { if (saveName == null || index < 1) { // User create new save slot TextInputDialog dialog = new TextInputDialog("Slot1"); dialog.setTitle(SAVE_DIALOG); dialog.setHeaderText("Please enter save state name:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { // name was inputed if (saveGameDao.isSaveExists(result.get())) { // duplicated name Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Save Error Dialog"); alert.setHeaderText("Save with this name exists."); alert.showAndWait(); return false; } else { // there are no saves with that name SaveGameDTO saveGame = game.getSaveGame(result.get()); saveGameDao.insertSave(saveGame); Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle(SAVE_DIALOG); alert.setHeaderText("You successfully save the game."); alert.showAndWait(); return true; } } else { // no name typed Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Save Error Dialog"); alert.setHeaderText("No name typed."); alert.showAndWait(); return false; } } else { // User override slot SaveGameDTO saveGame = game.getSaveGame(saveName); saveGameDao.updateSave(saveGame); Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle(SAVE_DIALOG); alert.setHeaderText("You successfully save the game."); alert.showAndWait(); return true; } }
@FXML protected void handleSubmitAction(ActionEvent event) throws IOException { String id = userIdField.getText(); String password = passwordField.getText(); RuleSet loginRules = RuleSetFactory.getRuleSet(this); ControllerInterface controller = SystemController.getInstance(); try { loginRules.applyRules(this); controller.login(id, password); Auth auth = SystemController.currentAuth; String fxmlFile = ""; switch (auth) { case ADMIN: fxmlFile = "../Admin.fxml"; break; case LIBRARIAN: fxmlFile = "../Librarian.fxml"; break; case BOTH: fxmlFile = "../MainMenu.fxml"; break; } Pane mainMenuRoot = FXMLLoader.load(getClass().getResource(fxmlFile)); Stage stage = new Stage(); stage.initModality(Modality.WINDOW_MODAL); stage.setTitle("Main Menu"); stage.setScene(new Scene(mainMenuRoot)); stage.show(); userIdField.clear(); passwordField.clear(); Stage loginStage = (Stage) submit.getScene().getWindow(); loginStage.close(); } catch (RuleException e1) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Login Error!"); alert.setHeaderText("Incorrect login information!"); alert.setContentText(e1.getMessage()); alert.show(); } catch (LoginException e) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Login Error!"); alert.setHeaderText("Incorrect login information!"); alert.setContentText(e.getMessage()); alert.show(); } }
public void alert() { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Warning"); alert.setHeaderText("Internet Connection"); alert.setContentText("No Internet Connection!"); alert.showAndWait(); }
public static void showInfoPopup(String title, String header, String content) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(title); alert.setHeaderText(header); alert.setContentText(content); alert.show(); }
public static void showErrorDialog(String header, String content) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(ResourceManager.getMessage("title.dialog.error")); alert.setHeaderText(header); alert.setContentText(content); alert.showAndWait(); }
@FXML private void handleDeleteDepartment() { int selectedIndex = departmentTable.getSelectionModel().getSelectedIndex(); if (selectedIndex >= 0) { for (int i = main.getEmployees().size() - 1; i >= 0; i--) { ViewEmployee vEmp = main.getEmployees().get(i); if (vEmp.getDepartment() .equals(departmentTable.getSelectionModel().getSelectedItem().getName())) { for (ViewDepartment vDep : main.getDepartments()) { if (vDep.getDirectorName().equals(vEmp.getLastName() + " " + vEmp.getFirstName())) { vDep.setDirectorName("-"); } } main.getEmployees().remove(vEmp); } } con.deleteDepartment(departmentTable.getSelectionModel().getSelectedItem().getId()); departmentTable.getItems().remove(selectedIndex); } else { Alert alert = new Alert(AlertType.WARNING); alert.initOwner(main.getPrimaryStage()); alert.setTitle("Ничего не выбрано"); alert.setHeaderText("Не выбран отдел"); alert.setContentText("Пожалуйста, выберите отдел"); alert.showAndWait(); } }
/** Met fin au programme et demande à l'utilisateur s'il veut sauvegarder. */ protected void quitter() { if (model.flagModif) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Sauvegarde du dictionnaire"); alert.setContentText("Voulez-vous enregistrer les nouvelles modifications au dictionnaire?"); alert.setHeaderText(null); ButtonType yes = new ButtonType("Oui"); ButtonType no = new ButtonType("Non"); alert.getButtonTypes().setAll(yes, no); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == yes) { try { model.sauvegardeFichier(); } catch (IOException e) { e.printStackTrace(); Alert alertSave = new Alert(AlertType.ERROR); alertSave.setTitle("IO Error"); alertSave.setContentText("Save File error"); alertSave.showAndWait(); } } } System.exit(0); }
public void getWarningAlert(String title, String headerText, String contentText) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(title); alert.setHeaderText(headerText); alert.setContentText(contentText); alert.showAndWait(); }
/** *************************Warning Pop Up Window************************** */ private void warning(String text) { Alert alert = new Alert(AlertType.WARNING); alert.setTitle("Warning"); alert.setHeaderText("Warning"); alert.setContentText(text); alert.showAndWait(); }
private void showErrorDialog(final String headerText, final String contentText) { final Alert alert = new Alert(AlertType.ERROR); // alert.setTitle("Error"); alert.setHeaderText(headerText); alert.setContentText(contentText); alert.showAndWait(); }
private void showDialog(String title, String message, Throwable throwable) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(title); alert.setHeaderText(title); alert.setContentText(message); StringWriter stringWriter = new StringWriter(); PrintWriter printwriter = new PrintWriter(stringWriter); throwable.printStackTrace(printwriter); String exceptionText = stringWriter.toString(); Label label = new Label("The exception stacktrace was:"); TextArea textArea = new TextArea(exceptionText); textArea.setEditable(false); textArea.setWrapText(true); textArea.setMaxWidth(Double.MAX_VALUE); textArea.setMaxHeight(Double.MAX_VALUE); GridPane.setVgrow(textArea, Priority.ALWAYS); GridPane.setHgrow(textArea, Priority.ALWAYS); GridPane expContent = new GridPane(); expContent.setMaxWidth(Double.MAX_VALUE); expContent.add(label, 0, 0); expContent.add(textArea, 0, 1); alert.getDialogPane().setExpandableContent(expContent); alert.showAndWait(); }
public DodanoPracownikaException() { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Uwaga!"); alert.setHeaderText(null); alert.setContentText("Zapisano dane pracownika"); alert.showAndWait(); }
public static void showWarningPopup(String title, String header, String content) { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle(title); alert.setHeaderText(header); alert.setContentText(content); alert.show(); }
public void validateAction() { if ((!this.emailFirstPart.getText().isEmpty()) && (!this.emailSecondPart.getText().isEmpty()) && (!this.emailThirdPart.getText().isEmpty())) { AppUser.user.setProfileImage(this.profileImageView.getImage()); AppUser.user.setEmail( this.emailFirstPart.getText() + "@" + this.emailSecondPart.getText() + "." + this.emailThirdPart.getText()); if (!this.passwordField1.getText().isEmpty()) { // TODO } this.stage.close(); } else { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Erreur"); alert.setHeaderText(null); alert.setContentText("Un des champs de l'addresse mail est vide."); alert.showAndWait(); } }
@FXML private void lvListenerGetEmployeeInfo(MouseEvent event) { try { tabPayCheck.setDisable(true); clearTextFields(); String[] a = lvEmployees.getSelectionModel().getSelectedItem().split("-"); tfInfoId.setText(a[1].trim()); final int ID = Integer.parseInt(tfInfoId.getText()); tfInfoName.setText(Environment.getEmployeeStrInfo(ID, "name")); tfInfoPos.setText(Environment.getEmployeeStrInfo(ID, "position")); tfInfoStreet.setText(Environment.getEmployeeStrInfo(ID, "street")); tfInfoCSZ.setText(Environment.getCityStateZip(ID)); tfInfoPayRate.setText( String.format("%.2f", Double.parseDouble(Environment.getEmployeeStrInfo(ID, "payRate")))); } catch (Exception e) { Alert alert; alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Error Message"); alert.setHeaderText("Whoops you did not select an Employee."); alert.setContentText("Try again."); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { // ... user chose OK } else { // ... user chose CANCEL or closed the dialog } } }
public static void alerta(String titulo, String mensagem, Alert.AlertType tipo) { Alert alert = new Alert(tipo); alert.setTitle(titulo); alert.setHeaderText(mensagem); alert.showAndWait(); }
@Override public void afterShow() { final boolean autostart = Boolean.parseBoolean(application.getParameters().getNamed().get("autostart")); if (autostart) { javafx.application.Platform.runLater( () -> { final Alert dialog = new Alert(AlertType.INFORMATION); dialog.initOwner(application.getPrimaryStage()); dialog.setHeaderText("Autostart in 10 seconds. Close this dialog to cancel"); dialog.show(); final Task<Void> sleeper = new Task<Void>() { @Override protected Void call() throws Exception { try { Thread.sleep(10000); } catch (final Exception e) { logger.log(Level.SEVERE, e.getMessage(), e); } return null; } }; sleeper.setOnSucceeded( event -> { if (dialog.isShowing()) { dialog.close(); startButton.fire(); } }); new Thread(sleeper, "autostartThread").start(); }); } }
/** * Displays alert that the user's temr is being changed to suggestion. * * @param term - original query. * @param suggestion - suggested query. */ private void spellCheckAlert(String term, String suggestion) { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle("No results found"); alert.setHeaderText("0 Results found for " + term + "."); alert.setContentText("Trying " + suggestion + " instead."); alert.showAndWait(); }
/** * Displays alert when there are no possible results. * * @param term - term that had no results. */ private void noResultError(String term) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("No results found"); alert.setHeaderText("0 Results found for " + term + "."); alert.setContentText("Try a different spelling or something."); alert.showAndWait(); }
public static void showInformationDialog(String message) { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Information"); alert.setHeaderText(null); alert.setContentText(message); alert.showAndWait(); }
public static void showErrorDialog(String message) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error"); alert.setHeaderText(null); alert.setContentText(message); alert.showAndWait(); }
public static void showWarnDialog(String message) { Alert alert = new Alert(AlertType.WARNING); alert.setTitle("Warning"); alert.setHeaderText(null); alert.setContentText(message); alert.showAndWait(); }
public void showAbout() { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("О программе"); alert.setHeaderText("Grain"); alert.setContentText("Программа для расчета цены за партию зерна."); alert.show(); }
@FXML public void onDragDroppedFolder(DragEvent event) { Dragboard dragboard = event.getDragboard(); File folder = dragboard.getFiles().get(0); DestinationFolder dest = new DestinationFolder(folder); if (this.repository.existsSameFolder(dest)) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("エラー"); alert.setHeaderText("既にフォルダが登録されています。"); alert.getDialogPane().setContentText(dest.getDestPath()); alert.show(); } else { TextInputDialog dialog = new TextInputDialog(); dialog.setTitle("フォルダ追加"); dialog.setContentText("フォルダ名"); dialog.setHeaderText(dest.getDestPath()); dialog.getEditor().setText(dest.getName()); dialog.setOnCloseRequest( e -> { TextInputDialog d = (TextInputDialog) e.getTarget(); String result = d.getResult(); if (result != null) { if (result.isEmpty()) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("エラー"); alert.setHeaderText("フォルダ名に空は指定できません。"); alert.show(); } else { dest.setName(result); this.repository.registerFolder(dest); this.destinationFolders = repository.findAll(); this.refreshDestFolderListView(); } } }); dialog.show(); } event.setDropCompleted(true); event.consume(); }
/** * @param event event of button * @throws GroupNotValidException not valid * @throws IDNotValidException not valid * @throws StringNotValidException not valid */ public final void onBtnGroupClick(final ActionEvent event) throws GroupNotValidException, IDNotValidException, StringNotValidException { try { Object item = disabled.getSelectionModel().getSelectedItem(); Button button = (Button) event.getSource(); // add a group if (button.getText().equals("<<")) { if (item.toString().equals("Arbeit")) { INACTIVEDATA.remove(item); ACTIVEDATA.add(item); c.addToGroup(Main.getWorkGroup()); } if (item.toString().equals("Familie")) { INACTIVEDATA.remove(item); ACTIVEDATA.add(item); c.addToGroup(Main.getFamilyGroup()); } if (item.toString().equals("Freunde")) { INACTIVEDATA.remove(item); ACTIVEDATA.add(item); c.addToGroup(Main.getFriendsGroup()); } } // remove a group item = enabled.getSelectionModel().getSelectedItem(); if (button.getText().equals(">>")) { if (item.toString().equals("Arbeit")) { ACTIVEDATA.remove(item); INACTIVEDATA.add(item); c.removeFromGroup(Main.getWorkGroup()); } if (item.toString().equals("Familie")) { ACTIVEDATA.remove(item); INACTIVEDATA.add(item); c.removeFromGroup(Main.getFamilyGroup()); } if (item.toString().equals("Freunde")) { ACTIVEDATA.remove(item); INACTIVEDATA.add(item); c.removeFromGroup(Main.getFriendsGroup()); } } } catch (Exception e) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Keine gültige Gruppe erkannt."); alert.setHeaderText(""); alert.setContentText("Es wurde keine gültige Gruppe erkannt. Klicke auf gültige Gruppe."); alert.showAndWait(); logger.log(Level.SEVERE, "Error: " + e.getMessage()); } }
public void showEDResult(List<String> path) { // intialize alert/dialog to display edit distance result Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Result"); alert.setHeaderText("Word Path : "); alert.initModality(Modality.NONE); alert.setResizable(true); // create layout for content VBox box = new VBox(); HBox midBox = new HBox(); box.setPadding(new Insets(35, 0, 35, 0)); box.setSpacing(35); midBox.setSpacing(15); Label pathLabel = new Label(); Label numStepsLabel = new Label("Number of steps : "); Label numSteps = new Label(); Font font = new Font(14); pathLabel.setFont(font); numStepsLabel.setFont(font); numSteps.setFont(Font.font(font.getFamily(), FontWeight.BOLD, 14)); midBox.getChildren().add(numStepsLabel); midBox.getChildren().add(numSteps); midBox.setAlignment(Pos.CENTER); box.getChildren().add(pathLabel); box.getChildren().add(midBox); box.setAlignment(Pos.CENTER); alert.getDialogPane().setPrefWidth(300); // check for path if (path != null) { numSteps.setText(Integer.toString(path.size() - 1)); pathLabel.setText(String.join(" -> ", path)); Text text = new Text(pathLabel.getText()); text.setFont(font); if (text.getLayoutBounds().getWidth() > 200) { alert.getDialogPane().setPrefWidth(text.getLayoutBounds().getWidth() + 100); } } // no path found else { pathLabel.setText("No Path Found."); numSteps.setText("N/A"); } // set content and styling alert.getDialogPane().setContent(box); alert .getDialogPane() .getStylesheets() .add(getClass().getResource("application.css").toExternalForm()); alert.getDialogPane().getStyleClass().add("myDialog"); alert.showAndWait(); }
private void confirmAlert() { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Item Accepted"); alert.setHeaderText(null); alert.setContentText("Item #" + itemCount + " accepted."); alert.show(); }