Example usage for javafx.scene.input KeyCombination match

List of usage examples for javafx.scene.input KeyCombination match

Introduction

In this page you can find the example usage for javafx.scene.input KeyCombination match.

Prototype

public boolean match(final KeyEvent event) 

Source Link

Document

Tests whether this key combination matches the combination in the given KeyEvent .

Usage

From source file:org.openbase.display.DisplayView.java

private void init(final Stage primaryStage) throws InterruptedException, InitializationException {

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override// w  w  w  . j  ava 2 s. co  m
        public void run() {
            Platform.exit();
        }
    });

    try {
        // platform configuration
        Platform.setImplicitExit(false);
        primaryStage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
        this.primaryStage = primaryStage;

        Scene scene = new Scene(cardsPane);

        // configure hide key combination
        final KeyCombination escapeKey = new KeyCodeCombination(KeyCode.ESCAPE);
        scene.addEventHandler(KeyEvent.KEY_RELEASED, new EventHandler<KeyEvent>() {

            @Override
            public void handle(KeyEvent event) {
                if (escapeKey.match(event)) {
                    try {
                        setVisible(false);
                    } catch (CouldNotPerformException ex) {
                        ExceptionPrinter.printHistory(
                                new CouldNotPerformException("Could not execute key event!", ex), logger);
                    }
                }
            }
        });

        primaryStage.setScene(scene);

        try {
            broadcastServer = new DisplayServer(this);
            broadcastServer.init(JPService.getProperty(JPBroadcastDisplayScope.class).getValue());
            broadcastServer.activate();
        } catch (JPServiceException | CouldNotPerformException ex) {
            throw new CouldNotPerformException("Could not load display server!", ex);
        }

        try {
            displayServer = new DisplayServer(this);
            displayServer.init(JPService.getProperty(JPDisplayScope.class).getValue());
            displayServer.activate();
        } catch (JPServiceException | CouldNotPerformException ex) {
            throw new CouldNotPerformException("Could not load display server!", ex);
        }
        this.htmlLoader.init(getScreen());
    } catch (CouldNotPerformException ex) {
        throw new InitializationException(this, ex);
    }
}