Java Code Examples for javafx.scene.control.Alert.AlertType#ERROR
The following examples show how to use
javafx.scene.control.Alert.AlertType#ERROR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlertMaker.java From Library-Assistant with Apache License 2.0 | 7 votes |
public static void showErrorMessage(Exception ex, String title, String content) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error occured"); alert.setHeaderText(title); alert.setContentText(content); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); ex.printStackTrace(pw); String exceptionText = sw.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(); }
Example 2
Source File: TargetDistancePane.java From ShootOFF with GNU General Public License v3.0 | 6 votes |
private boolean validateDistanceData() { boolean isValid = validateDistanceField(shooterDistance); isValid = validateDistanceField(targetDistance) && isValid; isValid = validateDistanceField(cameraDistance) && isValid; isValid = validateDistanceField(targetWidth) && isValid; isValid = validateDistanceField(targetHeight) && isValid; if (!isValid) return isValid; if ("0".equals(targetDistance.getText())) { final Alert invalidDataAlert = new Alert(AlertType.ERROR); final String message = "Target Distance cannot be 0, please set a value greater than 0."; invalidDataAlert.setTitle("Invalid Target Distance"); invalidDataAlert.setHeaderText("Target Distance Cannot Be Zero"); invalidDataAlert.setResizable(true); invalidDataAlert.setContentText(message); invalidDataAlert.initOwner(getScene().getWindow()); invalidDataAlert.showAndWait(); isValid = false; } return isValid; }
Example 3
Source File: EditorFrame.java From JetUML with GNU General Public License v3.0 | 6 votes |
private void save() { DiagramTab diagramTab = getSelectedDiagramTab(); Optional<File> file = diagramTab.getFile(); if(!file.isPresent()) { saveAs(); return; } try { PersistenceService.save(diagramTab.getDiagram(), file.get()); diagramTab.diagramSaved(); } catch(IOException exception) { Alert alert = new Alert(AlertType.ERROR, RESOURCES.getString("error.save_file"), ButtonType.OK); alert.initOwner(aMainStage); alert.showAndWait(); } }
Example 4
Source File: SaveAndRestoreController.java From phoebus with Eclipse Public License 1.0 | 5 votes |
private void createNewFolder(TreeItem<Node> parentTreeItem) { List<String> existingFolderNames = parentTreeItem.getChildren().stream() .filter(item -> item.getValue().getNodeType().equals(NodeType.FOLDER)) .map(item -> item.getValue().getName()) .collect(Collectors.toList()); TextInputDialog dialog = new TextInputDialog(); dialog.setTitle(Messages.contextMenuNewFolder); dialog.setContentText(Messages.promptNewFolder); dialog.setHeaderText(null); dialog.getDialogPane().lookupButton(ButtonType.OK).setDisable(true); dialog.getEditor().textProperty().addListener((observable, oldValue, newValue) -> { String value = newValue.trim(); dialog.getDialogPane().lookupButton(ButtonType.OK) .setDisable(existingFolderNames.contains(value) || value.isEmpty()); }); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { Node newFolderNode = Node.builder() .name(result.get()) .build(); try { Node newTreeNode = saveAndRestoreService .createNode(parentTreeItem.getValue().getUniqueId(), newFolderNode); parentTreeItem.getChildren().add(createNode(newTreeNode)); parentTreeItem.getChildren().sort((a, b) -> a.getValue().getName().compareTo(b.getValue().getName())); parentTreeItem.setExpanded(true); } catch (Exception e) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Action failed"); alert.setHeaderText(e.getMessage()); alert.showAndWait(); } } }
Example 5
Source File: ErrorDialogue.java From VocabHunter with Apache License 2.0 | 5 votes |
public ErrorDialogue(final I18nManager i18nManager, final I18nKey titleKey, final Throwable e, final String... messages) { alert = new Alert(AlertType.ERROR); alert.setTitle(i18nManager.text(titleKey)); alert.setHeaderText(headerText(messages)); TextArea textArea = new TextArea(exceptionText(e)); VBox expContent = new VBox(); DialogPane dialoguePane = alert.getDialogPane(); expContent.getChildren().setAll(new Label(i18nManager.text(ERROR_DETAILS)), textArea); dialoguePane.setExpandableContent(expContent); dialoguePane.expandedProperty().addListener(p -> Platform.runLater(this::resizeAlert)); dialoguePane.setId("errorDialogue"); }
Example 6
Source File: AlertMaker.java From Library-Assistant with Apache License 2.0 | 5 votes |
public static void showErrorMessage(String title, String content) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error"); alert.setHeaderText(title); alert.setContentText(content); styleAlert(alert); alert.showAndWait(); }
Example 7
Source File: CircuitSim.java From CircuitSim with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void saveCircuitsInternal() { try { saveCircuits(); } catch(Exception exc) { exc.printStackTrace(); Alert alert = new Alert(AlertType.ERROR); alert.initOwner(stage); alert.initModality(Modality.WINDOW_MODAL); alert.setTitle("Error"); alert.setHeaderText("Error saving circuit."); alert.setContentText("Error when saving the circuit: " + exc.getMessage()); alert.showAndWait(); } }
Example 8
Source File: SaveAndRestoreController.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** * Renames a node through the service and its underlying data provider. * If there is a problem in the call to the remote JMasar service, * the user is shown a suitable error dialog and the name of the node is restored. * @param node The node being renamed */ private void renameNode(TreeItem<Node> node){ List<String> existingSiblingNodes = node.getParent().getChildren().stream() .filter(item -> item.getValue().getNodeType().equals(node.getValue().getNodeType())) .map(item -> item.getValue().getName()) .collect(Collectors.toList()); TextInputDialog dialog = new TextInputDialog(); dialog.setTitle(Messages.promptRenameNodeTitle); dialog.setContentText(Messages.promptRenameNodeContent); dialog.setHeaderText(null); dialog.getDialogPane().lookupButton(ButtonType.OK).setDisable(true); dialog.getEditor().textProperty().setValue(node.getValue().getName()); dialog.getEditor().textProperty().addListener((observable, oldValue, newValue) -> { String value = newValue.trim(); dialog.getDialogPane().lookupButton(ButtonType.OK) .setDisable(existingSiblingNodes.contains(value) || value.isEmpty()); }); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { node.getValue().setName(result.get()); try { saveAndRestoreService.updateNode(node.getValue()); } catch (Exception e) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle(Messages.errorActionFailed); alert.setHeaderText(e.getMessage()); alert.showAndWait(); } } }
Example 9
Source File: DialogMediator.java From metastone with GNU General Public License v2.0 | 5 votes |
private void displayErrorMessage(String header, String message) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error"); alert.setHeaderText(header); alert.setContentText(message); alert.showAndWait(); }
Example 10
Source File: SaveAndRestoreWithSplitController.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** * Renames a node through the service and its underlying data provider. * If there is a problem in the call to the remote JMasar service, * the user is shown a suitable error dialog and the name of the node is restored. * @param node The node being renamed */ private void renameNode(TreeItem<Node> node){ List<String> existingSiblingNodes = node.getParent().getChildren().stream() .filter(item -> item.getValue().getNodeType().equals(node.getValue().getNodeType())) .map(item -> item.getValue().getName()) .collect(Collectors.toList()); TextInputDialog dialog = new TextInputDialog(); dialog.setTitle(Messages.promptRenameNodeTitle); dialog.setContentText(Messages.promptRenameNodeContent); dialog.setHeaderText(null); dialog.getDialogPane().lookupButton(ButtonType.OK).setDisable(true); dialog.getEditor().textProperty().setValue(node.getValue().getName()); dialog.getEditor().textProperty().addListener((observable, oldValue, newValue) -> { String value = newValue.trim(); dialog.getDialogPane().lookupButton(ButtonType.OK) .setDisable(existingSiblingNodes.contains(value) || value.isEmpty()); }); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { node.getValue().setName(result.get()); try { saveAndRestoreService.updateNode(node.getValue()); } catch (Exception e) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle(Messages.errorActionFailed); alert.setHeaderText(e.getMessage()); alert.showAndWait(); } } }
Example 11
Source File: App.java From java-ml-projects with Apache License 2.0 | 5 votes |
private void showError(String title, String message) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle(title); alert.setHeaderText(null); alert.setContentText(message); alert.showAndWait(); }
Example 12
Source File: DialogUtilsTest.java From PeerWasp with MIT License | 5 votes |
@Test public void testDecorateDialogWithIcon() { Alert dlg = new Alert(AlertType.ERROR); assertFalse(alertHasIcons(dlg)); DialogUtils.decorateDialogWithIcon(dlg); assertTrue(alertHasIcons(dlg)); }
Example 13
Source File: HomeScreenController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
@FXML public void showPreferences() { try { FXMLLoader fxmlLoader = new FXMLLoader( HomeScreenController.class.getResource( "Preferences.fxml" ), null, builderFactory, (clazz) -> injector.getInstance(clazz)); Parent prefsScreen = fxmlLoader.load(); Scene scene = new Scene(prefsScreen, 1024, 768 ); Stage stage = new Stage(); stage.setScene( scene ); stage.setTitle( "Preferences" ); stage.show(); } catch(Exception exc) { logger.error( "error showing preferences", exc); Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Preferences"); alert.setHeaderText("Error showing Preferences"); alert.setContentText(exc.getMessage()); alert.showAndWait(); } }
Example 14
Source File: DialogLoggerUtil.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public static void showErrorDialog(String message, Exception e) { Alert alert = new Alert(AlertType.ERROR, message + " \n" + e.getMessage()); alert.showAndWait(); }
Example 15
Source File: SaveAndRestoreController.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private void handleNewSaveSet(TreeItem<Node> parentTreeItem){ List<String> existingFolderNames = parentTreeItem.getChildren().stream() .filter(item -> item.getValue().getNodeType().equals(NodeType.CONFIGURATION)) .map(item -> item.getValue().getName()) .collect(Collectors.toList()); TextInputDialog dialog = new TextInputDialog(); dialog.setTitle(Messages.promptNewSaveSetTitle); dialog.setContentText(Messages.promptNewSaveSetContent); dialog.setHeaderText(null); dialog.getDialogPane().lookupButton(ButtonType.OK).setDisable(true); dialog.getEditor().textProperty().addListener((observable, oldValue, newValue) -> { String value = newValue.trim(); dialog.getDialogPane().lookupButton(ButtonType.OK) .setDisable(existingFolderNames.contains(value) || value.isEmpty()); }); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { Node newSateSetNode = Node.builder() .nodeType(NodeType.CONFIGURATION) .name(result.get()) .build(); try { Node newTreeNode = saveAndRestoreService .createNode(treeView.getSelectionModel().getSelectedItem().getValue().getUniqueId(), newSateSetNode); TreeItem<Node> newSaveSetNode = createNode(newTreeNode); parentTreeItem.getChildren().add(newSaveSetNode); parentTreeItem.getChildren().sort((a, b) -> a.getValue().getName().compareTo(b.getValue().getName())); parentTreeItem.setExpanded(true); nodeDoubleClicked(newSaveSetNode); treeView.getSelectionModel().select(treeView.getRow(newSaveSetNode)); } catch (Exception e) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Action failed"); alert.setHeaderText(e.getMessage()); alert.showAndWait(); } } }
Example 16
Source File: SaveAndRestoreWithSplitController.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private void handleNewSaveSet(TreeItem<Node> parentTreeItem){ List<String> existingFolderNames = parentTreeItem.getChildren().stream() .filter(item -> item.getValue().getNodeType().equals(NodeType.CONFIGURATION)) .map(item -> item.getValue().getName()) .collect(Collectors.toList()); TextInputDialog dialog = new TextInputDialog(); dialog.setTitle(Messages.promptNewSaveSetTitle); dialog.setContentText(Messages.promptNewSaveSetContent); dialog.setHeaderText(null); dialog.getDialogPane().lookupButton(ButtonType.OK).setDisable(true); dialog.getEditor().textProperty().addListener((observable, oldValue, newValue) -> { String value = newValue.trim(); dialog.getDialogPane().lookupButton(ButtonType.OK) .setDisable(existingFolderNames.contains(value) || value.isEmpty()); }); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { Node newSateSetNode = Node.builder() .nodeType(NodeType.CONFIGURATION) .name(result.get()) .build(); try { Node newTreeNode = saveAndRestoreService .createNode(treeView.getSelectionModel().getSelectedItem().getValue().getUniqueId(), newSateSetNode); TreeItem<Node> newSaveSetNode = createNode(newTreeNode); parentTreeItem.getChildren().add(newSaveSetNode); parentTreeItem.getChildren().sort((a, b) -> a.getValue().getName().compareTo(b.getValue().getName())); parentTreeItem.setExpanded(true); nodeDoubleClicked(newSaveSetNode); treeView.getSelectionModel().select(treeView.getRow(newSaveSetNode)); } catch (Exception e) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Action failed"); alert.setHeaderText(e.getMessage()); alert.showAndWait(); } } }
Example 17
Source File: EchoClientController.java From examples-javafx-repos1 with Apache License 2.0 | 4 votes |
@FXML public void send() { if( logger.isDebugEnabled() ) { logger.debug("[SEND]"); } if( !connected.get() ) { if( logger.isWarnEnabled() ) { logger.warn("client not connected; skipping write"); } return; } final String toSend = tfSend.getText(); Task<Void> task = new Task<Void>() { @Override protected Void call() throws Exception { ChannelFuture f = channel.writeAndFlush( Unpooled.copiedBuffer(toSend, CharsetUtil.UTF_8) ); f.sync(); return null; } @Override protected void failed() { Throwable exc = getException(); logger.error( "client send error", exc ); Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Client"); alert.setHeaderText( exc.getClass().getName() ); alert.setContentText( exc.getMessage() ); alert.showAndWait(); connected.set(false); } }; hboxStatus.visibleProperty().bind( task.runningProperty() ); lblStatus.textProperty().bind( task.messageProperty() ); piStatus.progressProperty().bind(task.progressProperty()); new Thread(task).start(); }
Example 18
Source File: EchoClientController.java From examples-javafx-repos1 with Apache License 2.0 | 4 votes |
@FXML public void disconnect() { if( !connected.get() ) { if( logger.isWarnEnabled() ) { logger.warn("client not connected; skipping disconnect"); } return; } if( logger.isDebugEnabled() ) { logger.debug("[DISCONNECT]"); } Task<Void> task = new Task<Void>() { @Override protected Void call() throws Exception { updateMessage("Disconnecting"); updateProgress(0.1d, 1.0d); channel.close().sync(); updateMessage("Closing group"); updateProgress(0.5d, 1.0d); group.shutdownGracefully().sync(); return null; } @Override protected void succeeded() { connected.set(false); } @Override protected void failed() { connected.set(false); Throwable t = getException(); logger.error( "client disconnect error", t ); Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Client"); alert.setHeaderText( t.getClass().getName() ); alert.setContentText( t.getMessage() ); alert.showAndWait(); } }; hboxStatus.visibleProperty().bind( task.runningProperty() ); lblStatus.textProperty().bind( task.messageProperty() ); piStatus.progressProperty().bind(task.progressProperty()); new Thread(task).start(); }
Example 19
Source File: EchoClientControllerWS.java From examples-javafx-repos1 with Apache License 2.0 | 4 votes |
@FXML public void disconnect() { if( !connected.get() ) { if( logger.isWarnEnabled() ) { logger.warn("client not connected; skipping disconnect"); } return; } if( logger.isDebugEnabled() ) { logger.debug("[DISCONNECT]"); } Task<Void> task = new Task<Void>() { @Override protected Void call() throws Exception { updateMessage("Disconnecting"); updateProgress(0.1d, 1.0d); channel.close().sync(); updateMessage("Closing group"); updateProgress(0.5d, 1.0d); group.shutdownGracefully().sync(); return null; } @Override protected void succeeded() { connected.set(false); } @Override protected void failed() { connected.set(false); Throwable t = getException(); logger.error( "client disconnect error", t ); Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Client"); alert.setHeaderText( t.getClass().getName() ); alert.setContentText( t.getMessage() ); alert.showAndWait(); } }; hboxStatus.visibleProperty().bind( task.runningProperty() ); lblStatus.textProperty().bind( task.messageProperty() ); piStatus.progressProperty().bind(task.progressProperty()); new Thread(task).start(); }
Example 20
Source File: Configuration.java From ShootOFF with GNU General Public License v3.0 | 4 votes |
public Optional<Camera> registerIpCam(String cameraName, String cameraURL, Optional<String> username, Optional<String> password) { try { final URL url = new URL(cameraURL); final Camera cam = IpCamera.registerIpCamera(cameraName, url, username, password); ipcams.put(cameraName, url); if (username.isPresent() && password.isPresent()) { ipcamCredentials.put(cameraName, username.get() + "|" + password.get()); } return Optional.of(cam); } catch (MalformedURLException | URISyntaxException ue) { final Alert ipcamURLAlert = new Alert(AlertType.ERROR); ipcamURLAlert.setTitle("Malformed URL"); ipcamURLAlert.setHeaderText("IPCam URL is Malformed!"); ipcamURLAlert.setResizable(true); ipcamURLAlert.setContentText("IPCam URL is not valid: \n\n" + ue.getMessage()); ipcamURLAlert.showAndWait(); } catch (final UnknownHostException uhe) { final Alert ipcamHostAlert = new Alert(AlertType.ERROR); ipcamHostAlert.setTitle("Unknown Host"); ipcamHostAlert.setHeaderText("IPCam URL Unknown!"); ipcamHostAlert.setResizable(true); ipcamHostAlert.setContentText("The IPCam at " + cameraURL + " cannot be resolved. Ensure the URL is correct " + "and that you are either connected to the internet or on the same network as the camera."); ipcamHostAlert.showAndWait(); } catch (final TimeoutException te) { final Alert ipcamTimeoutAlert = new Alert(AlertType.ERROR); ipcamTimeoutAlert.setTitle("IPCam Timeout"); ipcamTimeoutAlert.setHeaderText("Connection to IPCam Reached Timeout!"); ipcamTimeoutAlert.setResizable(true); ipcamTimeoutAlert.setContentText("Could not communicate with the IP at " + cameraURL + ". Please check the following:\n\n" + "-The IPCam URL is correct\n" + "-You are connected to the Internet (for external cameras)\n" + "-You are connected to the same network as the camera (for local cameras)"); ipcamTimeoutAlert.showAndWait(); } return Optional.empty(); }