Example usage for javafx.stage WindowEvent WindowEvent

List of usage examples for javafx.stage WindowEvent WindowEvent

Introduction

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

Prototype

public WindowEvent(final @NamedArg("source") Window source,
        final @NamedArg("eventType") EventType<? extends Event> eventType) 

Source Link

Document

Construct a new Event with the specified event source, target and type.

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:ca.wumbo.doommanager.client.controller.file.DXMLProjectCreatorController.java

/**
 * Tells the wizard to exit.//from  w w w  .j a v  a 2  s  .c  om
 */
public void exitWizard() {
    if (stage == null) {
        log.error("Attempting to close a stage without it being set.");
        return;
    }
    stage.fireEvent(new WindowEvent(parentStage, WindowEvent.WINDOW_CLOSE_REQUEST));
}

From source file:ca.wumbo.doommanager.client.controller.CoreController.java

/**
 * Attempts to terminate the application. This will request the main window
 * to close, and the closer listener will take care of any logic needed
 * before shutting down (like asking the user if that's what they want, and
 * to save anything... etc).//from  w w w.  j a v a  2  s  .co  m
 */
public void exit() {
    stage.fireEvent(new WindowEvent(stage, WindowEvent.WINDOW_CLOSE_REQUEST));
}

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

/**
 * Handler to close the application./*from ww  w.j  av a 2s  .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));
    }
}

From source file:com.properned.application.SystemController.java

@FXML
public void close() {
    logger.info("closed by menu");
    Properned.getInstance().getPrimaryStage().getOnCloseRequest().handle(
            new WindowEvent(Properned.getInstance().getPrimaryStage(), WindowEvent.WINDOW_CLOSE_REQUEST));
    Properned.getInstance().getPrimaryStage().close();
}

From source file:se.trixon.filebydate.ui.MainApp.java

private void initAccelerators() {
    final ObservableMap<KeyCombination, Runnable> accelerators = mStage.getScene().getAccelerators();

    accelerators.put(new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN), (Runnable) () -> {
        mStage.fireEvent(new WindowEvent(mStage, WindowEvent.WINDOW_CLOSE_REQUEST));
    });// w w w.j a  v a 2s.co  m

    accelerators.put(new KeyCodeCombination(KeyCode.N, KeyCombination.SHORTCUT_DOWN), (Runnable) () -> {
        profileEdit(null);
    });

    if (!IS_MAC) {
        accelerators.put(new KeyCodeCombination(KeyCode.COMMA, KeyCombination.SHORTCUT_DOWN), (Runnable) () -> {
            displayOptions();
        });
    }
}