Example usage for javafx.scene Scene setOnKeyReleased

List of usage examples for javafx.scene Scene setOnKeyReleased

Introduction

In this page you can find the example usage for javafx.scene Scene setOnKeyReleased.

Prototype

public final void setOnKeyReleased(EventHandler<? super KeyEvent> value) 

Source Link

Usage

From source file:org.pdfsam.ui.info.InfoStage.java

@Inject
public InfoStage(InfoPane infoPane, Collection<Image> logos, StylesConfig styles) {
    BorderPane containerPane = new BorderPane();
    containerPane.getStyleClass().addAll(Style.CONTAINER.css());
    containerPane.setCenter(infoPane);/*  www . ja  v  a  2s.co m*/
    containerPane.setBottom(new ClosePane());
    Scene scene = new Scene(containerPane);
    scene.getStylesheets().addAll(styles.styles());
    scene.setOnKeyReleased(new HideOnEscapeHandler(this));
    setScene(scene);
    setTitle(DefaultI18nContext.getInstance().i18n("Document details"));
    getIcons().addAll(logos);
    setMaximized(true);
}

From source file:org.pdfsam.ui.dialog.OverwriteConfirmationDialog.java

@Inject
public OverwriteConfirmationDialog(StylesConfig styles) {
    initModality(Modality.WINDOW_MODAL);
    initStyle(StageStyle.UTILITY);/*from  w  w w.ja  va 2  s.  c  o  m*/
    setResizable(false);
    BorderPane containerPane = new BorderPane();
    containerPane.getStyleClass().addAll(Style.CONTAINER.css());
    containerPane.getStyleClass().addAll("-pdfsam-dialog", "-pdfsam-warning-dialog");
    containerPane.setCenter(dialogContent);
    HBox buttons = new HBox(buildButton(DefaultI18nContext.getInstance().i18n("Overwrite"), true),
            buildButton(DefaultI18nContext.getInstance().i18n("Cancel"), false));
    buttons.getStyleClass().add("-pdfsam-dialog-buttons");
    containerPane.setBottom(buttons);
    Scene scene = new Scene(containerPane);
    scene.getStylesheets().addAll(styles.styles());
    scene.setOnKeyReleased(new HideOnEscapeHandler(this));
    setScene(scene);
}

From source file:org.pdfsam.ui.news.NewsStage.java

@Inject
public NewsStage(Collection<Image> logos, StylesConfig styles,
        @Named("newsDisplayPolicy") PreferenceComboBox<KeyStringValueItem<String>> newsDisplayPolicy) {
    BorderPane containerPane = new BorderPane();
    browser.setId("newsBrowser");
    containerPane.getStyleClass().addAll(Style.CONTAINER.css());
    containerPane.getStyleClass().add("-pdfsam-news-pane");
    containerPane.setCenter(browser);/*from ww w  . j ava2 s .c  o  m*/
    HBox bottom = new HBox();

    ClosePane closePane = new ClosePane();
    HBox.setHgrow(closePane, Priority.ALWAYS);
    HBox comboPanel = new HBox(new Label(DefaultI18nContext.getInstance().i18n("Show this:")),
            newsDisplayPolicy);
    comboPanel.getStyleClass().addAll(Style.CONTAINER.css());
    comboPanel.getStyleClass().add("-pdfsam-news-pane-bottom");
    bottom.getChildren().addAll(comboPanel, closePane);
    containerPane.setBottom(bottom);
    Scene scene = new Scene(containerPane);
    scene.getStylesheets().addAll(styles.styles());
    scene.setOnKeyReleased(new HideOnEscapeHandler(this));
    setScene(scene);
    setTitle(DefaultI18nContext.getInstance().i18n("What's new"));
    getIcons().addAll(logos);
    setMaximized(false);
}

From source file:io.bitsquare.app.gui.BitsquareApp.java

@Override
public void start(Stage primaryStage) throws IOException {
    bitsquareAppModule = new BitsquareAppModule(env, primaryStage);
    injector = Guice.createInjector(bitsquareAppModule);
    injector.getInstance(GuiceControllerFactory.class).setInjector(injector);

    // route uncaught exceptions to a user-facing dialog

    Thread.currentThread().setUncaughtExceptionHandler(
            (thread, throwable) -> Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable)));

    // initialize the application data directory (if necessary)

    initAppDir(env.getRequiredProperty(APP_DATA_DIR_KEY));

    // load and apply any stored settings

    User user = injector.getInstance(User.class);
    AccountSettings accountSettings = injector.getInstance(AccountSettings.class);
    Persistence persistence = injector.getInstance(Persistence.class);
    persistence.init();/* ww w  .  j ava2s .c o  m*/

    User persistedUser = (User) persistence.read(user);
    user.applyPersistedUser(persistedUser);

    accountSettings.applyPersistedAccountSettings(
            (AccountSettings) persistence.read(accountSettings.getClass().getName()));

    // load the main view and create the main scene

    ViewLoader viewLoader = injector.getInstance(ViewLoader.class);
    ViewLoader.Item loaded = viewLoader.load(Navigation.Item.MAIN.getFxmlUrl(), false);

    Scene scene = new Scene((Parent) loaded.view, 1000, 600);
    scene.getStylesheets().setAll("/io/bitsquare/gui/bitsquare.css", "/io/bitsquare/gui/images.css");

    // configure the system tray

    SystemTray systemTray = new SystemTray(primaryStage, this::stop);
    primaryStage.setOnCloseRequest(e -> stop());
    scene.setOnKeyReleased(keyEvent -> {
        // For now we exit when closing/quit the app.
        // Later we will only hide the window (systemTray.hideStage()) and use the exit item in the system tray for
        // shut down.
        if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(keyEvent)
                || new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN).match(keyEvent))
            stop();
    });

    // configure the primary stage

    primaryStage.setTitle(env.getRequiredProperty(APP_NAME_KEY));
    primaryStage.setScene(scene);
    primaryStage.setMinWidth(75);
    primaryStage.setMinHeight(50);

    // on windows the title icon is also used as task bar icon in a larger size
    // on Linux no title icon is supported but also a large task bar icon is derived form that title icon
    String iconPath;
    if (Utilities.isOSX())
        iconPath = ImageUtil.isRetina() ? "/images/window_icon@2x.png" : "/images/window_icon.png";
    else if (Utilities.isWindows())
        iconPath = "/images/task_bar_icon_windows.png";
    else
        iconPath = "/images/task_bar_icon_linux.png";

    if (iconPath != null)
        primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(iconPath)));

    // make the UI visible

    primaryStage.show();
}

From source file:de.ks.text.AsciiDocEditor.java

@FXML
void showPreviewPopup() {
    if (previewPopupStage == null) {
        String title = Localized.get("adoc.preview");

        previewPopupStage = new Stage();
        previewPopupStage.setTitle(title);
        Scene scene = new Scene(new StackPane(popupPreviewNode));
        scene.setOnKeyReleased(e -> {
            if (e.getCode() == KeyCode.ESCAPE) {
                previewPopupStage.close();
            }//from   w  w  w .  ja  va 2s  .  c om
        });
        previewPopupStage.setScene(scene);

        Rectangle2D bounds = new ScreenResolver().getScreenToShow().getBounds();
        previewPopupStage.setX(bounds.getMinX());
        previewPopupStage.setY(bounds.getMinY());
        previewPopupStage.setWidth(bounds.getWidth());
        previewPopupStage.setHeight(bounds.getHeight());

        previewPopupStage.initModality(Modality.NONE);
        previewPopupStage.setOnShowing(e -> {
            popupPreview.showDirect(getText());
        });
        previewPopupStage.setOnCloseRequest(e -> this.previewPopupStage = null);
        previewPopupStage.show();
    }
}

From source file:acmi.l2.clientmod.l2smr.Controller.java

private void showUmodel(final String obj, final String file) {
    Platform.runLater(() -> {/*from   w  w  w  .  ja v  a  2  s. c  o m*/
        try {
            FXMLLoader loader = new FXMLLoader(getClass().getResource("smview/smview.fxml"));
            loader.load();
            SMView controller = loader.getController();
            controller.setStaticmesh(getStaticMeshDir(), file, obj);
            Scene scene = new Scene(loader.getRoot());
            scene.setOnKeyReleased(controller::onKeyReleased);

            Stage smStage = new Stage();
            smStage.setScene(scene);
            smStage.setTitle(obj);
            smStage.show();

            smStage.setX(Double.parseDouble(L2smr.getPrefs().get("smview.x", String.valueOf(smStage.getX()))));
            smStage.setY(Double.parseDouble(L2smr.getPrefs().get("smview.y", String.valueOf(smStage.getY()))));
            smStage.setWidth(Double
                    .parseDouble(L2smr.getPrefs().get("smview.width", String.valueOf(smStage.getWidth()))));
            smStage.setHeight(Double
                    .parseDouble(L2smr.getPrefs().get("smview.height", String.valueOf(smStage.getHeight()))));

            InvalidationListener listener = observable -> {
                L2smr.getPrefs().put("smview.x", String.valueOf(Math.round(smStage.getX())));
                L2smr.getPrefs().put("smview.y", String.valueOf(Math.round(smStage.getY())));
                L2smr.getPrefs().put("smview.width", String.valueOf(Math.round(smStage.getWidth())));
                L2smr.getPrefs().put("smview.height", String.valueOf(Math.round(smStage.getHeight())));
            };
            smStage.xProperty().addListener(listener);
            smStage.yProperty().addListener(listener);
            smStage.widthProperty().addListener(listener);
            smStage.heightProperty().addListener(listener);
        } catch (IOException e) {
            onException("Couldn't show staticmesh", e);
        }
    });
}