public void exit() { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Quit?"); alert.setHeaderText("You've selected to quit this program."); alert.setContentText("Are you sure you want to quit?"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) System.exit(0); }
public void viewOrder() { String currentOrder = ""; int counter = 0; for (Item i : order.getOrder()) { counter++; currentOrder += counter + ". " + i.toString() + "\n"; } Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Current Order"); alert.setHeaderText("Your current order is as follows:"); alert.setContentText(currentOrder); alert.getDialogPane().setStyle(" -fx-max-width:500px; -fx-pref-width: 500px;"); alert.showAndWait(); }