Example usage for javafx.scene.input KeyEvent KEY_RELEASED

List of usage examples for javafx.scene.input KeyEvent KEY_RELEASED

Introduction

In this page you can find the example usage for javafx.scene.input KeyEvent KEY_RELEASED.

Prototype

EventType KEY_RELEASED

To view the source code for javafx.scene.input KeyEvent KEY_RELEASED.

Click Source Link

Document

This event occurs when a key has been released.

Usage

From source file:com.heliosdecompiler.helios.gui.controller.MenuBarController.java

@FXML
private void initialize() {
    stage.addEventFilter(KeyEvent.KEY_RELEASED, event -> {
        if (event.isShortcutDown() && event.getCode() == KeyCode.O) {
            onOpen();//w  w  w .  ja  v  a 2s.c o  m
        }
    });
    stage.addEventFilter(KeyEvent.KEY_RELEASED, event -> {
        if (event.isShortcutDown() && event.getCode() == KeyCode.N) {
            onReset();
        }
    });
    stage.addEventFilter(KeyEvent.KEY_RELEASED, event -> {
        if (event.getCode() == KeyCode.F5) {
            getParentController().getFileTreeController().reload();
        }
    });

    try {
        GuiceFXMLLoader.Result result = loader.load(getClass().getResource("/views/pathEditor.fxml"));
        pathEditorController = result.getController();
    } catch (IOException ex) {
        messageHandler.handleException(Message.ERROR_UNKNOWN_ERROR.format(), ex);
    }
    try {
        GuiceFXMLLoader.Result result = loader.load(getClass().getResource("/views/transformerSettings.fxml"));
        transformerSettingsController = result.getController();
    } catch (IOException ex) {
        messageHandler.handleException(Message.ERROR_UNKNOWN_ERROR.format(), ex);
    }

    // for mac (and maybe linux once java supports it)
    // todo refactor into UIController
    root.setUseSystemMenuBar(true);
}

From source file:Main.java

public static java.awt.event.KeyEvent toAwt(final KeyEvent event) {
    final EventType type = event.getEventType();
    if (null == type) {
        return null;
    }/*w  w  w  .j a  v  a  2 s. c o  m*/

    final int id;
    if (KeyEvent.KEY_TYPED.equals(type)) {
        id = java.awt.event.KeyEvent.KEY_TYPED;
    } else if (KeyEvent.KEY_PRESSED.equals(type)) {
        id = java.awt.event.KeyEvent.KEY_PRESSED;
    } else if (KeyEvent.KEY_RELEASED.equals(type)) {
        id = java.awt.event.KeyEvent.KEY_RELEASED;
    } else {
        return null;
    }

    final long when = -1;
    final int modifiers = modifiers(event);
    final int keyCode = keyCode(event);
    final String keyValue = event.getCharacter();
    final char keyChar = keyValue != null && !keyValue.isEmpty() ? keyValue.charAt(0) : ' ';
    return new java.awt.event.KeyEvent(empty, id, when, modifiers, keyCode, keyChar);
}

From source file:bzh.terrevirtuelle.navisu.instruments.gps.plotter.impl.controller.GpsPlotterController.java

protected void addPanelController() {
    Platform.runLater(() -> {/*from www  .j  a  v  a 2  s  .  c o m*/
        targetPanel = new TargetPanel(guiAgentServices, KeyCode.B, KeyCombination.CONTROL_DOWN);
        guiAgentServices.getScene().addEventFilter(KeyEvent.KEY_RELEASED, targetPanel);
        guiAgentServices.getRoot().getChildren().add(targetPanel);
        targetPanel.setScale(1.0);
        targetPanel.setVisible(false);
    });
}

From source file:ijfx.ui.filter.DefaultNumberFilter.java

public DefaultNumberFilter() {
    try {/*from   ww w .  ja  v a2  s.c  o m*/
        FXUtilities.injectFXML(this);

        borderPane.setTop(rangeSlider);

        //            areaChart.setCategoryGap(0);
        rangeSlider.setShowTickLabels(true);
        areaChart.setOnMouseClicked(event -> update());

        rangeSlider.lowValueChangingProperty().addListener(this::onLowHighValueChanged);
        rangeSlider.highValueChangingProperty().addListener(this::onLowHighValueChanged);

        rangeSlider.lowValueProperty().addListener(this::onLowHighValueChanged);
        rangeSlider.highValueProperty().addListener(this::onLowHighValueChanged);

        categoryAxis.upperBoundProperty().bind(rangeSlider.maxProperty());
        categoryAxis.lowerBoundProperty().bind(rangeSlider.minProperty());
        categoryAxis.minorTickCountProperty().bind(rangeSlider.minorTickCountProperty());
        categoryAxis.tickUnitProperty().bind(rangeSlider.majorTickUnitProperty());
        converter.setFloatingPoint(true);
        converter.floatingPointNumberProperty().bind(Bindings.createIntegerBinding(
                this::getDisplayedFloatingPoint, rangeSlider.minProperty(), rangeSlider.maxProperty()));

        new TextToNumberBinding(lowTextField, rangeSlider.lowValueProperty());
        new TextToNumberBinding(highTextField, rangeSlider.highValueProperty());

        //Bindings.bindBidirectional(lowTextField.textProperty(), rangeSlider.lowValueProperty(), converter);
        //Bindings.bindBidirectional(highTextField.textProperty(), rangeSlider.highValueProperty(), converter);

        lowTextField.addEventFilter(KeyEvent.KEY_RELEASED, this::updatePredicate);
        highTextField.addEventHandler(KeyEvent.KEY_PRESSED, this::updatePredicate);

        rangeSlider.getStyleClass().add("range-slider");

    } catch (IOException ex) {
        Logger.getLogger(DefaultNumberFilter.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.heliosdecompiler.helios.gui.controller.FileTreeController.java

@FXML
public void initialize() {
    this.rootItem = new TreeItem<>(new TreeNode("[root]"));
    this.root.setRoot(this.rootItem);
    this.root.setCellFactory(new TreeCellFactory<>(node -> {
        if (node.getParent() == null) {
            ContextMenu export = new ContextMenu();

            MenuItem exportItem = new MenuItem("Export");

            export.setOnAction(e -> {
                File file = messageHandler.chooseFile().withInitialDirectory(new File("."))
                        .withTitle(Message.GENERIC_CHOOSE_EXPORT_LOCATION_JAR.format())
                        .withExtensionFilter(new FileFilter(Message.FILETYPE_JAVA_ARCHIVE.format(), "*.jar"),
                                true)/*  ww  w  . j  a  v  a  2s. co  m*/
                        .promptSave();

                OpenedFile openedFile = (OpenedFile) node.getMetadata().get(OpenedFile.OPENED_FILE);

                Map<String, byte[]> clone = new HashMap<>(openedFile.getContents());

                backgroundTaskHelper.submit(
                        new BackgroundTask(Message.TASK_SAVING_FILE.format(node.getDisplayName()), true, () -> {
                            try {
                                if (!file.exists()) {
                                    if (!file.createNewFile()) {
                                        throw new IOException("Could not create export file");
                                    }
                                }

                                try (ZipOutputStream zipOutputStream = new ZipOutputStream(
                                        new FileOutputStream(file))) {
                                    for (Map.Entry<String, byte[]> ent : clone.entrySet()) {
                                        ZipEntry zipEntry = new ZipEntry(ent.getKey());
                                        zipOutputStream.putNextEntry(zipEntry);
                                        zipOutputStream.write(ent.getValue());
                                        zipOutputStream.closeEntry();
                                    }
                                }

                                messageHandler.handleMessage(Message.GENERIC_EXPORTED.format());
                            } catch (IOException ex) {
                                messageHandler.handleException(Message.ERROR_IOEXCEPTION_OCCURRED.format(), ex);
                            }
                        }));
            });

            export.getItems().add(exportItem);
            return export;
        }
        return null;
    }));

    root.addEventHandler(KeyEvent.KEY_RELEASED, event -> {
        if (event.getCode() == KeyCode.ENTER) {
            TreeItem<TreeNode> selected = this.root.getSelectionModel().getSelectedItem();
            if (selected != null) {
                if (selected.getChildren().size() != 0) {
                    selected.setExpanded(!selected.isExpanded());
                } else {
                    getParentController().getAllFilesViewerController().handleClick(selected.getValue());
                }
            }
        }
    });

    Tooltip tooltip = new Tooltip();
    StringBuilder search = new StringBuilder();

    List<TreeItem<TreeNode>> searchContext = new ArrayList<>();
    AtomicInteger searchIndex = new AtomicInteger();

    root.focusedProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue) {
            tooltip.hide();
            search.setLength(0);
        }
    });

    root.boundsInLocalProperty().addListener((observable, oldValue, newValue) -> {
        Bounds bounds = root.localToScreen(newValue);
        tooltip.setAnchorX(bounds.getMinX());
        tooltip.setAnchorY(bounds.getMinY());
    });

    root.addEventHandler(KeyEvent.KEY_PRESSED, event -> {
        if (tooltip.isShowing() && event.getCode() == KeyCode.UP) {
            if (searchIndex.decrementAndGet() < 0) {
                searchIndex.set(searchContext.size() - 1);
            }
        } else if (tooltip.isShowing() && event.getCode() == KeyCode.DOWN) {
            if (searchIndex.incrementAndGet() >= searchContext.size()) {
                searchIndex.set(0);
            }
        } else {
            return;
        }
        event.consume();

        root.scrollTo(root.getRow(searchContext.get(searchIndex.get())));
        root.getSelectionModel().select(searchContext.get(searchIndex.get()));
    });

    root.addEventHandler(KeyEvent.KEY_TYPED, event -> {
        if (event.getCharacter().charAt(0) == '\b') {
            if (search.length() > 0) {
                search.setLength(search.length() - 1);
            }
        } else if (event.getCharacter().charAt(0) == '\u001B') { //esc
            tooltip.hide();
            search.setLength(0);
            return;
        } else if (search.length() > 0
                || (search.length() == 0 && StringUtils.isAlphanumeric(event.getCharacter()))) {
            search.append(event.getCharacter());
            if (!tooltip.isShowing()) {
                tooltip.show(root.getScene().getWindow());
            }
        }

        if (!tooltip.isShowing())
            return;

        String str = search.toString();
        tooltip.setText("Search for: " + str);

        searchContext.clear();

        ArrayDeque<TreeItem<TreeNode>> deque = new ArrayDeque<>();
        deque.addAll(rootItem.getChildren());

        while (!deque.isEmpty()) {
            TreeItem<TreeNode> item = deque.poll();
            if (item.getValue().getDisplayName().contains(str)) {
                searchContext.add(item);
            }
            if (item.isExpanded() && item.getChildren().size() > 0)
                deque.addAll(item.getChildren());
        }

        searchIndex.set(0);
        if (searchContext.size() > 0) {
            root.scrollTo(root.getRow(searchContext.get(0)));
            root.getSelectionModel().select(searchContext.get(0));
        }
    });

    openedFileController.loadedFiles().addListener((MapChangeListener<String, OpenedFile>) change -> {
        if (change.getValueAdded() != null) {
            updateTree(change.getValueAdded());
        }
        if (change.getValueRemoved() != null) {
            this.rootItem.getChildren()
                    .removeIf(ti -> ti.getValue().equals(change.getValueRemoved().getRoot()));
        }
    });
}

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

@Override
public void start(Stage stage) throws IOException {
    BitsquareApp.primaryStage = stage;/* ww w.  j a  va2s.  com*/

    String logPath = Paths.get(env.getProperty(AppOptionKeys.APP_DATA_DIR_KEY), "bitsquare").toString();
    Log.setup(logPath);
    log.info("Log files under: " + logPath);
    Version.printVersion();
    Utilities.printSysInfo();
    Log.setLevel(Level.toLevel(env.getRequiredProperty(CommonOptionKeys.LOG_LEVEL_KEY)));

    UserThread.setExecutor(Platform::runLater);
    UserThread.setTimerClass(UITimer.class);

    shutDownHandler = this::stop;

    // setup UncaughtExceptionHandler
    Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {
        // Might come from another thread 
        if (throwable.getCause() != null && throwable.getCause().getCause() != null
                && throwable.getCause().getCause() instanceof BlockStoreException) {
            log.error(throwable.getMessage());
        } else if (throwable instanceof ClassCastException
                && "sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData"
                        .equals(throwable.getMessage())) {
            log.warn(throwable.getMessage());
        } else {
            log.error("Uncaught Exception from thread " + Thread.currentThread().getName());
            log.error("throwableMessage= " + throwable.getMessage());
            log.error("throwableClass= " + throwable.getClass());
            log.error("Stack trace:\n" + ExceptionUtils.getStackTrace(throwable));
            throwable.printStackTrace();
            UserThread.execute(() -> showErrorPopup(throwable, false));
        }
    };
    Thread.setDefaultUncaughtExceptionHandler(handler);
    Thread.currentThread().setUncaughtExceptionHandler(handler);

    try {
        Utilities.checkCryptoPolicySetup();
    } catch (NoSuchAlgorithmException | LimitedKeyStrengthException e) {
        e.printStackTrace();
        UserThread.execute(() -> showErrorPopup(e, true));
    }

    Security.addProvider(new BouncyCastleProvider());

    try {
        // Guice
        bitsquareAppModule = new BitsquareAppModule(env, primaryStage);
        injector = Guice.createInjector(bitsquareAppModule);
        injector.getInstance(InjectorViewFactory.class).setInjector(injector);

        Version.setBtcNetworkId(injector.getInstance(BitsquareEnvironment.class).getBitcoinNetwork().ordinal());

        if (Utilities.isLinux())
            System.setProperty("prism.lcdtext", "false");

        Storage.setDatabaseCorruptionHandler((String fileName) -> {
            corruptedDatabaseFiles.add(fileName);
            if (mainView != null)
                mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
        });

        // load the main view and create the main scene
        CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
        mainView = (MainView) viewLoader.load(MainView.class);
        mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);

        /* Storage.setDatabaseCorruptionHandler((String fileName) -> {
        corruptedDatabaseFiles.add(fileName);
        if (mainView != null)
            mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
         });*/

        scene = new Scene(mainView.getRoot(), 1200, 700); //740

        Font.loadFont(getClass().getResource("/fonts/Verdana.ttf").toExternalForm(), 13);
        Font.loadFont(getClass().getResource("/fonts/VerdanaBold.ttf").toExternalForm(), 13);
        Font.loadFont(getClass().getResource("/fonts/VerdanaItalic.ttf").toExternalForm(), 13);
        Font.loadFont(getClass().getResource("/fonts/VerdanaBoldItalic.ttf").toExternalForm(), 13);
        scene.getStylesheets().setAll("/io/bitsquare/gui/bitsquare.css", "/io/bitsquare/gui/images.css",
                "/io/bitsquare/gui/CandleStickChart.css");

        // configure the system tray
        SystemTray.create(primaryStage, shutDownHandler);

        primaryStage.setOnCloseRequest(event -> {
            event.consume();
            stop();
        });
        scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEvent -> {
            if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(keyEvent)
                    || new KeyCodeCombination(KeyCode.W, KeyCombination.CONTROL_DOWN).match(keyEvent)) {
                stop();
            } else if (new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN).match(keyEvent)
                    || new KeyCodeCombination(KeyCode.Q, KeyCombination.CONTROL_DOWN).match(keyEvent)) {
                stop();
            } else if (new KeyCodeCombination(KeyCode.E, KeyCombination.SHORTCUT_DOWN).match(keyEvent)
                    || new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN).match(keyEvent)) {
                showEmptyWalletPopup();
            } else if (new KeyCodeCombination(KeyCode.M, KeyCombination.ALT_DOWN).match(keyEvent)) {
                showSendAlertMessagePopup();
            } else if (new KeyCodeCombination(KeyCode.F, KeyCombination.ALT_DOWN).match(keyEvent)) {
                showFilterPopup();
            } else if (new KeyCodeCombination(KeyCode.F, KeyCombination.ALT_DOWN).match(keyEvent)) {
                showFPSWindow();
            } else if (new KeyCodeCombination(KeyCode.J, KeyCombination.ALT_DOWN).match(keyEvent)) {
                WalletService walletService = injector.getInstance(WalletService.class);
                if (walletService.getWallet() != null)
                    new ShowWalletDataWindow(walletService).information("Wallet raw data").show();
                else
                    new Popup<>().warning("The wallet is not initialized yet").show();
            } else if (new KeyCodeCombination(KeyCode.G, KeyCombination.ALT_DOWN).match(keyEvent)) {
                TradeWalletService tradeWalletService = injector.getInstance(TradeWalletService.class);
                WalletService walletService = injector.getInstance(WalletService.class);
                if (walletService.getWallet() != null)
                    new SpendFromDepositTxWindow(tradeWalletService).information("Emergency wallet tool")
                            .show();
                else
                    new Popup<>().warning("The wallet is not initialized yet").show();
            } else if (DevFlags.DEV_MODE
                    && new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) {
                showDebugWindow();
            }
        });

        // configure the primary stage
        primaryStage.setTitle(env.getRequiredProperty(APP_NAME_KEY));
        primaryStage.setScene(scene);
        primaryStage.setMinWidth(1000); // 1190
        primaryStage.setMinHeight(620);

        // 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 from 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";

        primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(iconPath)));

        // make the UI visible
        primaryStage.show();

        if (!Utilities.isCorrectOSArchitecture()) {
            String osArchitecture = Utilities.getOSArchitecture();
            // We don't force a shutdown as the osArchitecture might in strange cases return a wrong value.
            // Needs at least more testing on different machines...
            new Popup<>()
                    .warning("You probably have the wrong Bitsquare version for this computer.\n"
                            + "Your computer's architecture is: " + osArchitecture + ".\n"
                            + "The Bitsquare binary you installed is: " + Utilities.getJVMArchitecture() + ".\n"
                            + "Please shut down and re-install the correct version (" + osArchitecture + ").")
                    .show();
        }

        UserThread.runPeriodically(() -> Profiler.printSystemLoad(log), LOG_MEMORY_PERIOD_MIN,
                TimeUnit.MINUTES);

    } catch (Throwable throwable)

    {
        showErrorPopup(throwable, false);
    }

}

From source file:com.exalttech.trex.ui.views.PacketTableView.java

/**
 * Build component UI/*  w  w w.ja  v a  2s.  c  o m*/
 */
private void buildUI(boolean addExportToYamlBtn) {
    setTopAnchor(this, 0d);
    setLeftAnchor(this, 0d);
    setBottomAnchor(this, 0d);
    setRightAnchor(this, 0d);
    // build btn bar
    HBox buttonContainer = new HBox();
    buttonContainer.setSpacing(5);
    addPacketBtn = new StreamTableButton(StreamTableAction.ADD);
    initializeStreamButtons(addPacketBtn, false);
    buttonContainer.getChildren().add(addPacketBtn);

    // add build stream btn
    buildPacketBtn = new StreamTableButton(StreamTableAction.BUILD);
    buildPacketBtn.setId("buildStreamBtn");
    initializeStreamButtons(buildPacketBtn, false);
    buttonContainer.getChildren().add(buildPacketBtn);

    editPacketBtn = new StreamTableButton(StreamTableAction.EDIT);
    editPacketBtn.setId("editStreanBtn");
    initializeStreamButtons(editPacketBtn, true);
    buttonContainer.getChildren().add(editPacketBtn);

    deleteButtonBtn = new StreamTableButton(StreamTableAction.DELETE);
    initializeStreamButtons(deleteButtonBtn, true);
    buttonContainer.getChildren().add(deleteButtonBtn);

    importPcapButton = new StreamTableButton(StreamTableAction.IMPORT_PCAP);
    initializeStreamButtons(importPcapButton, false);
    buttonContainer.getChildren().add(importPcapButton);

    exportPcapButton = new StreamTableButton(StreamTableAction.EXPORT_TO_PCAP);
    initializeStreamButtons(exportPcapButton, true);
    buttonContainer.getChildren().add(exportPcapButton);

    if (addExportToYamlBtn) {
        exportToYaml = new StreamTableButton(StreamTableAction.EXPORT_TO_YAML);
        initializeStreamButtons(exportToYaml, false);
        buttonContainer.getChildren().add(exportToYaml);
    }
    getChildren().add(buttonContainer);
    setTopAnchor(buttonContainer, 5d);

    rightClickMenu = new ContextMenu();
    addMenuItem(StreamTableAction.EDIT);
    addMenuItem(StreamTableAction.DELETE);
    addMenuItem(StreamTableAction.EXPORT_TO_PCAP);
    addMenuItem(StreamTableAction.EXPORT_TO_YAML);

    // add table view
    streamPacketTableView = new TableView<>();
    streamPacketTableView.setId("streamTableView");
    streamPacketTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    streamPacketTableView.setFixedCellSize(32);
    streamPacketTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    streamPacketTableView.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            handleTableRowClick(event);
        }
    });

    streamPacketTableView.getSelectionModel().selectedItemProperty()
            .addListener((ObservableValue<? extends TableProfileStream> observable, TableProfileStream oldValue,
                    TableProfileStream newValue) -> {
                boolean notSelected = !(newValue != null);

                exportPcapButton.setDisable(notSelected);
                editPacketBtn.setDisable(notSelected);
                deleteButtonBtn.setDisable(notSelected);
            });

    streamPacketTableView.addEventFilter(KeyEvent.KEY_RELEASED, (KeyEvent event) -> {
        if (copyCombination.match(event)) {
            selectedProfile = tabledata.getProfiles()
                    .get(streamPacketTableView.getSelectionModel().getSelectedIndex());
        } else if (pasteCombination.match(event)) {
            handleDuplicateStream();
        } else if (event.getCode() == KeyCode.DELETE) {
            handleDeletePacket();
        }
    });
    streamPacketTableView.setEditable(true);
    initializeTableColumn();
    // disable table reordering
    streamPacketTableView.widthProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> source, Number oldWidth, Number newWidth) {
            TableHeaderRow header = (TableHeaderRow) streamPacketTableView.lookup("TableHeaderRow");
            header.reorderingProperty().addListener(new ChangeListener<Boolean>() {
                @Override
                public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue,
                        Boolean newValue) {
                    header.setReordering(false);
                }
            });
        }
    });

    getChildren().add(streamPacketTableView);
    setTopAnchor(streamPacketTableView, 35d);
    setBottomAnchor(streamPacketTableView, 5d);
    setLeftAnchor(streamPacketTableView, 0d);
    setRightAnchor(streamPacketTableView, 0d);
}

From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java

/**
 * @param graphicsComponent The graphics component the key code is typed in, may be null
 * @param keycode The key code.//from ww w  .  j av a 2 s.c o  m
 * @param isUpperCase Boolean whether character is upper case.
 */
public void keyType(Object graphicsComponent, int keycode, boolean isUpperCase) throws RobotException {
    try {
        InterceptorOptions options = new InterceptorOptions(new long[] { AWTEvent.KEY_EVENT_MASK });
        IRobotEventConfirmer confirmer = m_interceptor.intercept(options);
        try {
            if (isUpperCase) {
                m_robot.keyPress(java.awt.event.KeyEvent.VK_SHIFT);
            }
            m_robot.keyPress(keycode);
        } finally {
            m_robot.keyRelease(keycode);
            if (isUpperCase) {
                m_robot.keyRelease(java.awt.event.KeyEvent.VK_SHIFT);
            }
        }
        confirmer.waitToConfirm(graphicsComponent, new KeyJavaFXEventMatcher(KeyEvent.KEY_RELEASED));
    } catch (IllegalArgumentException e) {
        throw new RobotException(e);
    }
}

From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java

/**
 * Implements the key press or release.//from w  ww  .j  av  a2  s. c o  m
 *
 * @param graphicsComponent
 *            The component, may be <code>null</code>
 * @param keyCode
 *            The key code
 * @param press
 *            If <code>true</code>, the key is pressed, otherwise released
 */
private void keyPressReleaseImpl(Object graphicsComponent, int keyCode, boolean press) {

    InterceptorOptions options = new InterceptorOptions(new long[] { AWTEvent.KEY_EVENT_MASK });
    IRobotEventConfirmer confirmer = m_interceptor.intercept(options);
    if (press) {
        m_robot.keyPress(keyCode);
    } else {
        m_robot.keyRelease(keyCode);
    }
    confirmer.waitToConfirm(graphicsComponent,
            new KeyJavaFXEventMatcher(press ? KeyEvent.KEY_PRESSED : KeyEvent.KEY_RELEASED));
}

From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java

/**
 * {@inheritDoc}//w w w .  j a  v a 2s . com
 */
public void keyStroke(String keyStrokeSpec) throws RobotException {
    try {
        KeyTyper.getInstance().type(keyStrokeSpec, m_interceptor,
                new KeyJavaFXEventMatcher(KeyEvent.KEY_PRESSED),
                new KeyJavaFXEventMatcher(KeyEvent.KEY_RELEASED));
    } catch (AWTException e) {
        throw new RobotException(e);
    }
}