Java Code Examples for javafx.scene.control.Alert#setTitle()

The following examples show how to use javafx.scene.control.Alert#setTitle() . 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: InterruptibleProcessController.java    From chvote-1-0 with GNU Affero General Public License v3.0 6 votes vote down vote up
private void showAlert(ProcessInterruptedException e) {
    Alert alert = new Alert(Alert.AlertType.ERROR);
    ResourceBundle resources = getResourceBundle();
    alert.setTitle(resources.getString("exception_alert.title"));
    alert.setHeaderText(resources.getString("exception_alert.header"));
    alert.setContentText(e.getMessage());

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    String exceptionText = sw.toString();

    Label stackTraceLabel = new Label(resources.getString("exception_alert.label"));
    TextArea stackTraceTextArea = new TextArea(exceptionText);
    stackTraceTextArea.setEditable(false);
    stackTraceTextArea.setWrapText(true);
    GridPane.setVgrow(stackTraceTextArea, Priority.ALWAYS);
    GridPane.setHgrow(stackTraceTextArea, Priority.ALWAYS);

    GridPane expandableContent = new GridPane();
    expandableContent.setPrefSize(400, 400);
    expandableContent.setMaxWidth(Double.MAX_VALUE);
    expandableContent.add(stackTraceLabel, 0, 0);
    expandableContent.add(stackTraceTextArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expandableContent);
    // Dirty Linux only fix...
    // Expandable zones cause the dialog not to resize correctly
    if (System.getProperty("os.name").matches(".*[Ll]inux.*")) {
        alert.getDialogPane().setPrefSize(600, 400);
        alert.setResizable(true);
        alert.getDialogPane().setExpanded(true);
    }

    alert.showAndWait();
}
 
Example 2
Source File: DockItem.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Show info dialog */
private void showInfo()
{
    final Alert dlg = new Alert(AlertType.INFORMATION);
    dlg.setTitle(Messages.DockInfo);

    // No DialogPane 'header', all info is in the 'content'
    dlg.setHeaderText("");

    final StringBuilder info = new StringBuilder();
    fillInformation(info);
    final TextArea content = new TextArea(info.toString());
    content.setEditable(false);
    content.setPrefSize(300, 100);
    content.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    dlg.getDialogPane().setContent(content);

    DialogHelper.positionDialog(dlg, name_tab, 0, 0);
    dlg.setResizable(true);
    dlg.showAndWait();
}
 
Example 3
Source File: Movimientos.java    From uip-pc2 with MIT License 6 votes vote down vote up
public void atras(MouseEvent mouseEvent) {
    Stage stage = (Stage) atras.getScene().getWindow();
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Resumen.fxml"));
    Parent root = null;
    try {
        root = fxmlLoader.load();
    } catch (Exception e) {
        Alert alerta = new Alert(Alert.AlertType.ERROR);
        alerta.setTitle("Error de Aplicación");
        alerta.setContentText("Llama al lapecillo de sistemas.");
        alerta.showAndWait();
        Platform.exit();
    }
    FadeTransition ft = new FadeTransition(Duration.millis(1500), root);
    ft.setFromValue(0.0);
    ft.setToValue(1.0);
    ft.play();
    Resumen controller = fxmlLoader.<Resumen>getController();
    controller.setCuenta();
    controller.setSaldo();
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();
}
 
Example 4
Source File: MainWindow.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void helpAbout() {
	String version = null;
	Package pkg = this.getClass().getPackage();
	if (pkg != null)
		version = pkg.getImplementationVersion();
	if (version == null)
		version = "(dev)";

	Alert alert = new Alert(AlertType.INFORMATION);
	alert.setTitle(Messages.get("MainWindow.about.title"));
	alert.setHeaderText(Messages.get("MainWindow.about.headerText"));
	alert.setContentText(Messages.get("MainWindow.about.contentText", version));
	alert.setGraphic(new ImageView(new Image("org/markdownwriterfx/markdownwriterfx32.png")));
	alert.initOwner(getScene().getWindow());
	alert.getDialogPane().setPrefWidth(420);

	alert.showAndWait();
}
 
Example 5
Source File: FileEditerController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public boolean checkBeforeNextAction() {
    if (fileChanged == null || !fileChanged.getValue()) {
        return true;
    } else {
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle(getMyStage().getTitle());
        alert.setContentText(AppVariables.message("NeedSaveBeforeAction"));
        alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
        ButtonType buttonSave = new ButtonType(AppVariables.message("Save"));
        ButtonType buttonNotSave = new ButtonType(AppVariables.message("NotSave"));
        ButtonType buttonCancel = new ButtonType(AppVariables.message("Cancel"));
        alert.getButtonTypes().setAll(buttonSave, buttonNotSave, buttonCancel);
        Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
        stage.setAlwaysOnTop(true);
        stage.toFront();

        Optional<ButtonType> result = alert.showAndWait();
        if (result.get() == buttonSave) {
            saveAction();
            return false;
        } else {
            return result.get() == buttonNotSave;
        }
    }
}
 
Example 6
Source File: Transferencia.java    From uip-pc2 with MIT License 6 votes vote down vote up
public void salir(MouseEvent mouseEvent) {
    Stage stage = (Stage) salir.getScene().getWindow();
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Login.fxml"));
    Parent root = null;
    try {
        root = fxmlLoader.load();
    } catch (Exception e) {
        Alert alerta = new Alert(Alert.AlertType.ERROR);
        alerta.setTitle("Error de Aplicación");
        alerta.setContentText("Llama al lapecillo de sistemas.");
        alerta.showAndWait();
        Platform.exit();
    }
    FadeTransition ft = new FadeTransition(Duration.millis(1500), root);
    ft.setFromValue(0.0);
    ft.setToValue(1.0);
    ft.play();
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();
}
 
Example 7
Source File: EpidemicReportsImportBaiduController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
protected void afterSuccess() {
    if (statisticCheck.isSelected()) {
        startStatistic();
    } else {
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle("MyBox");
        alert.setContentText(message("EpidemicReportStatistic"));
        alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
        ButtonType buttonOK = new ButtonType(AppVariables.message("OK"));
        ButtonType buttonCancel = new ButtonType(AppVariables.message("Cancel"));
        alert.getButtonTypes().setAll(buttonOK, buttonCancel);
        Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
        stage.setAlwaysOnTop(true);
        stage.toFront();
        Optional<ButtonType> result = alert.showAndWait();
        if (result.get() == buttonOK) {
            startStatistic();
        }
    }
}
 
Example 8
Source File: Controller2.java    From uip-pc2 with MIT License 6 votes vote down vote up
public void salir(ActionEvent actionEvent) {
    Stage stage = (Stage) btn_salir.getScene().getWindow();
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("sample.fxml"));
    Parent root = null;
    try {
        root = fxmlLoader.load();
    } catch (Exception e) {
        Alert alerta = new Alert(Alert.AlertType.ERROR);
        alerta.setTitle("Error de Aplicación");
        alerta.setContentText("Llama al lapecillo de sistemas.");
        alerta.showAndWait();
        Platform.exit();
    }
    FadeTransition ft = new FadeTransition(Duration.millis(1500), root);
    ft.setFromValue(0.0);
    ft.setToValue(1.0);
    ft.play();
    //? controller = fxmlLoader.<?>getController();
    //controller.setConteo(conteo);
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();
}
 
Example 9
Source File: ImageViewerController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public boolean deleteFile(File sfile) {
    if (sfile == null) {
        return false;
    }
    if (deleteConfirmCheck != null && deleteConfirmCheck.isSelected()) {
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle(getMyStage().getTitle());
        alert.setContentText(AppVariables.message("SureDelete"));
        alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
        ButtonType buttonSure = new ButtonType(AppVariables.message("Sure"));
        ButtonType buttonCancel = new ButtonType(AppVariables.message("Cancel"));
        alert.getButtonTypes().setAll(buttonSure, buttonCancel);
        Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
        stage.setAlwaysOnTop(true);
        stage.toFront();

        Optional<ButtonType> result = alert.showAndWait();
        if (result.get() != buttonSure) {
            return false;
        }
    }
    if (sfile.delete()) {
        popSuccessful();
        return true;
    } else {
        popFailed();
        return false;
    }
}
 
Example 10
Source File: App.java    From PeerWasp with MIT License 5 votes vote down vote up
/**
 * Shows an alert dialog with an error message.
 * Blocks until dialog closed.
 *
 * @param title of dialog
 * @param message of error
 */
private void showErrorAlert(String title, String message) {
	Alert dlg = DialogUtils.createAlert(AlertType.ERROR);
	dlg.setTitle("Error - Initialization");
	dlg.setHeaderText(title);
	dlg.setContentText(message);
	dlg.showAndWait();
}
 
Example 11
Source File: NeutralLossSetHighlightDialog.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
private void displayMessage(String msg) {
  logger.info(msg);
  final Alert alert = new Alert(Alert.AlertType.ERROR);
  alert.initStyle(StageStyle.UTILITY);
  alert.setTitle("Information");
  alert.setHeaderText("Error");
  alert.setContentText(msg);
  alert.showAndWait();
}
 
Example 12
Source File: ImageManufactureController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@Override
public boolean checkBeforeNextAction() {
    if (!imageLoaded.get() || !imageUpdated.get()) {
        return true;
    }
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle(getMyStage().getTitle());
    alert.setContentText(AppVariables.message("ImageChanged"));
    alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
    ButtonType buttonSave = new ButtonType(AppVariables.message("Save"));
    ButtonType buttonSaveAs = new ButtonType(AppVariables.message("SaveAs"));
    ButtonType buttonNotSave = new ButtonType(AppVariables.message("NotSave"));
    ButtonType buttonCancel = new ButtonType(AppVariables.message("Cancel"));
    alert.getButtonTypes().setAll(buttonSave, buttonSaveAs, buttonNotSave, buttonCancel);
    Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
    stage.setAlwaysOnTop(true);
    stage.toFront();

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == buttonSave) {
        saveAction();
        return true;
    } else if (result.get() == buttonNotSave) {
        return true;
    } else if (result.get() == buttonSaveAs) {
        saveAsAction();
        return true;
    } else {
        return false;
    }

}
 
Example 13
Source File: OptionsPathDialogController.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@FXML
private void doChooser(final ActionEvent actionEvent)
{
	DirectoryChooser directoryChooser = new DirectoryChooser();
	String modelDirectory = model.directoryProperty().getValue();
	if (!modelDirectory.isBlank())
	{
		directoryChooser.setInitialDirectory(new File(model.directoryProperty().getValue()));
	}

	File dir = directoryChooser.showDialog(optionsPathDialogScene.getWindow());

	if (dir != null)
	{
		if (dir.listFiles().length > 0)
		{
			Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
			alert.setTitle("Directory Not Empty");
			alert.setContentText("The folder " + dir.getAbsolutePath() + " is not empty.\n"
					+ "All ini files in this directory may be overwritten. " + "Are you sure?");
			Optional<ButtonType> buttonType = alert.showAndWait();
			buttonType.ifPresent(option -> {
				if (option != ButtonType.YES)
				{
					return;
				}
			});
		}
		model.directoryProperty().setValue(dir.getAbsolutePath());
	}
}
 
Example 14
Source File: ListAddController.java    From MythRedisClient with Apache License 2.0 5 votes vote down vote up
/**
 * 判断输入的是否为数字.
 * @return true为数字
 */
private boolean isNum() {
    boolean ok = false;
    String input = valueText.getText();
    try {
        Double.parseDouble(input);
        ok = true;
    } catch (Exception e) {
        Alert alert = MyAlert.getInstance(Alert.AlertType.ERROR);
        alert.setTitle("错误");
        alert.setContentText("请输入数字");
        alert.showAndWait();
    }
    return ok;
}
 
Example 15
Source File: MultiplayerTray.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public void createAlert(String text) {
   	//Stage stage = new Stage();
       stage.getIcons().add(new Image(this.getClass().getResource("/icons/lander_hab.svg").toString()));
       String header = null;
       //String text = null;
       header = "Multiplayer Host Server";
       //System.out.println("confirm dialog pop up.");
	Alert alert = new Alert(AlertType.CONFIRMATION);
	alert.initOwner(stage);
	alert.setTitle("Mars Simulation Project");
	alert.setHeaderText(header);
	alert.setContentText(text);
	alert.initModality(Modality.APPLICATION_MODAL);

	Optional<ButtonType> result = alert.showAndWait();
	if (result.get() == ButtonType.YES){
		if (multiplayerServer != null) {
        	// TODO: fix the loading problem for server mode
        	multiplayerServer.setServerStopped(true);
        }
		notificationTimer.cancel();
		Platform.exit();
		tray.remove(trayIcon);
	    System.exit(0);
	}
	//else {
	//}
}
 
Example 16
Source File: FxUtils.java    From Sword_emulator with GNU General Public License v3.0 5 votes vote down vote up
public static void showException(Throwable throwable) {
    throwable.printStackTrace();
    Alert information = new Alert(Alert.AlertType.ERROR);
    information.setTitle(throwable.getClass().getSimpleName());
    information.setHeaderText(throwable.getMessage());
    information.showAndWait();
}
 
Example 17
Source File: AppUtils.java    From java-ml-projects with Apache License 2.0 5 votes vote down vote up
public static void showErrorDialog(String title, String content) {
	Alert dialog = new Alert(Alert.AlertType.ERROR);
	dialog.setTitle(title);
	dialog.setHeaderText(null);
	dialog.setResizable(true);
	dialog.setContentText(content);
	dialog.showAndWait();
}
 
Example 18
Source File: OptionsPathDialogController.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@FXML
private void doChooser(final ActionEvent actionEvent)
{
	DirectoryChooser directoryChooser = new DirectoryChooser();
	String modelDirectory = model.directoryProperty().getValue();
	if (!modelDirectory.isBlank())
	{
		directoryChooser.setInitialDirectory(new File(model.directoryProperty().getValue()));
	}

	File dir = directoryChooser.showDialog(optionsPathDialogScene.getWindow());

	if (dir != null)
	{
		if (dir.listFiles().length > 0)
		{
			Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
			alert.setTitle("Directory Not Empty");
			alert.setContentText("The folder " + dir.getAbsolutePath() + " is not empty.\n"
					+ "All ini files in this directory may be overwritten. " + "Are you sure?");
			Optional<ButtonType> buttonType = alert.showAndWait();
			buttonType.ifPresent(option -> {
				if (option != ButtonType.YES)
				{
					return;
				}
			});
		}
		model.directoryProperty().setValue(dir.getAbsolutePath());
	}
}
 
Example 19
Source File: ValidationController.java    From School-Management-System with Apache License 2.0 5 votes vote down vote up
public boolean numbersOnly(TextField txt) {
    if (txt.getText().matches("[0-9]+")) {

        return true;
    } else {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Student Registration");
        alert.setHeaderText(null);
        alert.setContentText("Invalid Input Type..!");
        alert.showAndWait();

        return false;
    }
}
 
Example 20
Source File: EchoClientControllerWS.java    From examples-javafx-repos1 with Apache License 2.0 4 votes vote down vote up
@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();
}