Example usage for javafx.stage Stage fireEvent

List of usage examples for javafx.stage Stage fireEvent

Introduction

In this page you can find the example usage for javafx.stage Stage fireEvent.

Prototype

public final void fireEvent(Event event) 

Source Link

Document

Fires the specified event.

Usage

From source file:com.ggvaidya.scinames.ui.DatasetImporterController.java

@FXML
private void cancelImport(ActionEvent e) {
    // Close this without resetting the controller.
    // From http://stackoverflow.com/a/29711376/27310

    Stage stage = datasetImporterView.getStage();

    stage.fireEvent(new WindowEvent(stage, WindowEvent.WINDOW_CLOSE_REQUEST));
}

From source file:de.bayern.gdi.gui.Controller.java

/**
 * Handler to close the application./*from  w ww  .  ja v a 2 s  .c  o  m*/
 *
 * @param event The event.
 */
@FXML
protected void handleCloseApp(ActionEvent event) {
    Alert closeDialog = new Alert(Alert.AlertType.CONFIRMATION);
    closeDialog.setTitle(I18n.getMsg("gui.confirm-exit"));
    closeDialog.setContentText(I18n.getMsg("gui.want-to-quit"));
    ButtonType confirm = new ButtonType(I18n.getMsg("gui.exit"));
    ButtonType cancel = new ButtonType(I18n.getMsg("gui.cancel"), ButtonData.CANCEL_CLOSE);
    closeDialog.getButtonTypes().setAll(confirm, cancel);
    Optional<ButtonType> res = closeDialog.showAndWait();
    if (res.isPresent() && res.get() == confirm) {
        logToAppLog(I18n.format("dlc.stop"));
        Stage stage = (Stage) buttonClose.getScene().getWindow();
        stage.fireEvent(new WindowEvent(stage, WindowEvent.WINDOW_CLOSE_REQUEST));
    }
}