/* /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); } }
// @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()); } }
/** 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); }
@FXML private void calcular() { try { if (interprete.checarParentesis(txtFuncion.getText())) { interprete.setFuncion(txtFuncion.getText()); if (truncamiento.isSelected()) { interprete.setTipoValores(1); } else { interprete.setTipoValores(2); } getK(); txtResultado.setText( interprete.getFlotante(new BigDecimal(interprete.getResultado())) + ""); setOperaciones(); } else { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Información"); alert.setContentText( "Error de sintaxis. Verifique que haya escrito la función correctamente"); alert.showAndWait(); } } catch (Exception e) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Información"); alert.setContentText( "Error de sintaxis. Verifique que haya escrito la función correctamente"); alert.showAndWait(); } }
/** * prints out either the shopping List or the Overview of the items in stock depending on the type * * @param type */ public void printOut(PrintOutType type) { boolean output = false; String fileToPrint = ""; switch (type) { case OVERVIEW: output = SaveToFile.printOut(new ArrayList<ItemBox>(items), type, false); fileToPrint = "Overview.txt"; break; case SHOPPING: ArrayList<ItemBox> temp = new ArrayList<>(); // adds every Item which has an amount of 0 to the shopping list for (ItemBox item : items) { if (item.getAmount() == 0) { temp.add(item); } } output = SaveToFile.printOut(temp, type, false); fileToPrint = "Shopping.txt"; break; } if (output) { log.debug(type.name() + " Successfully Saved PrintFile"); File file = new File(System.getProperty("user.home") + "/Desktop/" + fileToPrint); if (file != null) { boolean printOut = Printing.printFile(file); if (printOut) { log.debug("Successfully printed File"); Alert alert = Alerter.getAlert(AlertType.INFORMATION, "Print", null, "Successfully printed."); alert.showAndWait(); } else { log.debug("File was saved but could not be printed"); Alert alert = Alerter.getAlert( AlertType.INFORMATION, "Print Failed", null, "File saved but could not be printed."); alert.showAndWait(); } } } else { Alert alert = Alerter.getAlert( AlertType.INFORMATION, "Error", null, "File could not be saved and printed."); alert.showAndWait(); log.debug(type.name() + "PrintFile could NOT be saved and printed"); } }
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; } }
/** * if the barcode hasn't already got a name on outpan.com the item will be listed online with the * passed name * * @param gtin * @param name */ private void listNewItem(String gtin, String name) { try { URL url = new URL( "https://api.outpan.com/v2/products/" + gtin + "/name" + "?apikey=e13a9fb0bda8684d72bc3dba1b16ae1e"); HttpsURLConnection httpCon = (HttpsURLConnection) url.openConnection(); httpCon.setDoOutput(true); httpCon.setRequestMethod("POST"); // replaces umlauts, ß, ", ' and / name = IllegalStringReplacer.replaceIllegalChars(name); String content = "name=" + name; DataOutputStream out = new DataOutputStream(httpCon.getOutputStream()); out.writeBytes(content); out.flush(); log.debug(httpCon.getResponseCode() + " - " + httpCon.getResponseMessage()); out.close(); if (httpCon.getResponseCode() == 200) { Alert alert = Alerter.getAlert(AlertType.INFORMATION, "Item Added", null, "Item is now listed."); alert.showAndWait(); log.info("Item '" + name + "' now listed"); addItem(gtin); } else { log.debug("Item could not be listed"); Alert alert = Alerter.getAlert( AlertType.WARNING, "Item not Added", null, "Item could not be listed, please try again."); alert.showAndWait(); } } catch (MalformedURLException e) { log.error("MalformedURLException: " + e.getMessage()); } catch (IOException e) { log.error("IOException: " + e.getMessage()); } }
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(); } }
public DodanoPracownikaException() { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Uwaga!"); alert.setHeaderText(null); alert.setContentText("Zapisano dane pracownika"); alert.showAndWait(); }
@FXML void processLoadGame(ActionEvent event) { GestorLogs.registrarLog("Reanudando Juego..."); String fxml = ConstantesFXML.FXML_REANUDAR_JUEGO; ReanudarJuegoController controller; try { Stage reanudarJuegoStage = new Stage(); controller = (ReanudarJuegoController) FXUtils.cargarStage( reanudarJuegoStage, fxml, "Monopoly - Reanudar juego", false, false, Modality.APPLICATION_MODAL, StageStyle.UTILITY); controller.setCurrentStage(reanudarJuegoStage); controller.setPrevStage(currentStage); controller.setUsuarioLogueado(usuarioLogueado); int senderId = ConnectionController.getInstance().getIdPlayer(); ConnectionController.getInstance().send(new GetSavedGamesMessage(senderId, usuarioLogueado)); } catch (Exception ex) { GestorLogs.registrarException(ex); final Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error..."); alert.setContentText(ex.getMessage()); alert.getButtonTypes().setAll(new ButtonType("Aceptar", ButtonData.OK_DONE)); 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(); } }
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(); }
public void alert() { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Warning"); alert.setHeaderText("Internet Connection"); alert.setContentText("No Internet Connection!"); 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 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(); }
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(); }
/** *************************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(); }
public static void alerta(String titulo, String mensagem, Alert.AlertType tipo) { Alert alert = new Alert(tipo); alert.setTitle(titulo); alert.setHeaderText(mensagem); alert.showAndWait(); }
/** * 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(); }
@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 } } }
/** * 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(); }
private boolean esEjemplarValido() { if (txtCodigoEjemplar.getText() == null || txtCodigoEjemplar.getText().length() == 0) { Alert error = Help.getHelp( Alert.AlertType.ERROR, "Cine", null, "DPI no valido, " + "por favor ingrese un valor!"); error.showAndWait(); txtCodigoEjemplar.requestFocus(); return false; } if (txtLocalizacion.getText() == null || txtLocalizacion.getText().length() == 0) { Alert error = Help.getHelp( Alert.AlertType.ERROR, "Cine", null, "Nombre no valido, " + "por favor ingrese un valor!"); error.showAndWait(); txtLocalizacion.requestFocus(); return false; } if (txtCodigoLibro.getText() == null || txtCodigoLibro.getText().length() == 0) { Alert error = Help.getHelp( Alert.AlertType.ERROR, "Cine", null, "Apellido no valido, " + "por favor ingrese un valor!"); error.showAndWait(); txtCodigoLibro.requestFocus(); return false; } if (txtCodigoUsuario.getText() == null || txtCodigoUsuario.getText().length() == 0) { Alert error = Help.getHelp( Alert.AlertType.ERROR, "Cine", null, "Direccion no valida, " + "por favor ingrese un valor!"); error.showAndWait(); txtCodigoUsuario.requestFocus(); return false; } return true; }
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(); }
/** * @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 static void showErrorAlter(String title, String contents) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle(title); alert.setHeaderText(null); alert.setContentText(contents); alert.showAndWait(); }
public static void showInformationAlter(String title, String contents) { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle(title); alert.setHeaderText(null); alert.setContentText(contents); alert.showAndWait(); }
/** * Shows dialog for user input error * * @param inErr - message to dispaly */ public void showInputErrorDialog(String inErr) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error"); alert.setHeaderText("Input Error"); alert.setContentText(inErr); alert.showAndWait(); }