Example usage for javafx.scene.input KeyCode DOWN

List of usage examples for javafx.scene.input KeyCode DOWN

Introduction

In this page you can find the example usage for javafx.scene.input KeyCode DOWN.

Prototype

KeyCode DOWN

To view the source code for javafx.scene.input KeyCode DOWN.

Click Source Link

Document

Constant for the non-numpad down arrow key.

Usage

From source file:com.playonlinux.javafx.mainwindow.console.ConsoleTab.java

public ConsoleTab(CommandLineInterpreterFactory commandLineInterpreterFactory) {
    final VBox content = new VBox();

    commandInterpreter = commandLineInterpreterFactory.createInstance();

    this.setText(translate("Console"));
    this.setContent(content);

    final TextField command = new TextField();
    command.getStyleClass().add("consoleCommandType");
    final TextFlow console = new TextFlow();
    final ScrollPane consolePane = new ScrollPane(console);
    content.getStyleClass().add("rightPane");

    consolePane.getStyleClass().add("console");
    consolePane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    content.getChildren().addAll(consolePane, command);

    command.requestFocus();/* www.  ja  v  a  2 s.com*/

    command.setOnKeyPressed(event -> {
        if (event.getCode() == KeyCode.ENTER) {
            final String commandToSend = command.getText();
            final int cursorPosition = command.getCaretPosition();
            command.setDisable(true);
            commandHistory.add(new CommandHistory.Item(commandToSend, cursorPosition));
            Text commandText = new Text(nextSymbol + commandToSend + "\n");
            commandText.getStyleClass().add("commandText");
            console.getChildren().add(commandText);
            command.setText("");

            if (commandInterpreter.sendLine(commandToSend, message -> {
                Platform.runLater(() -> {
                    if (!StringUtils.isBlank(message)) {
                        Text resultText = new Text(message);
                        resultText.getStyleClass().add("resultText");
                        console.getChildren().add(resultText);
                    }
                    command.setDisable(false);
                    command.requestFocus();
                    consolePane.setVvalue(consolePane.getVmax());
                });
            })) {
                nextSymbol = NOT_INSIDE_BLOCK;
            } else {
                nextSymbol = INSIDE_BLOCK;
            }
        }
    });

    command.setOnKeyReleased(event -> {
        if (event.getCode() == KeyCode.UP) {
            CommandHistory.Item historyItem = commandHistory.up();
            command.setText(historyItem.getCommand());
            command.positionCaret(historyItem.getCursorPosition());
        } else if (event.getCode() == KeyCode.DOWN) {
            CommandHistory.Item historyItem = commandHistory.down();
            command.setText(historyItem.getCommand());
            command.positionCaret(historyItem.getCursorPosition());
        }
    });

    this.setOnCloseRequest(event -> commandInterpreter.close());
}

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

@FXML
private void initialize() {
    textField.setOnKeyPressed(event -> {
        // Submit any text on enter.
        if (event.getCode().equals(KeyCode.ENTER))
            submitLineToConsole();//from  w  w  w . j a v  a2s.  c  om

        // If we press up/down, look for lines we stored.
        if (event.getCode().equals(KeyCode.UP) || event.getCode().equals(KeyCode.DOWN)) {
            if (commandBuffer.size() > 0) {
                commandBufferIndex += (event.getCode().equals(KeyCode.UP) ? -1 : 1);
                commandBufferIndex = Math.min(Math.max(0, commandBufferIndex), commandBuffer.size());
                textField.setText(commandBufferIndex == commandBuffer.size() ? ""
                        : commandBuffer.get(commandBufferIndex));
                textField.end();
                event.consume(); // Has to be consumed or else it will mess up the end() caret setting.
            } else {
                textField.setText("");
            }
        }
    });
}

From source file:by.zuyeu.deyestracker.reader.ui.readpane.ReadPaneController.java

private void addScrollTracker() throws DEyesTrackerException {
    LOG.info("addScrollTracker() - start;");
    if (!scrollExist) {
        application.getStage().addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent evt) -> {
            if (evt.getCode().equals(KeyCode.DOWN)) {
                Platform.runLater(() -> {
                    LOG.debug("down - vvalue = {}", spText.getVvalue());
                    spText.setVvalue(spText.getVvalue() + spText.getVmax() / 10);
                });/*from w  ww .  jav  a  2  s  . c o m*/
            }
            if (evt.getCode().equals(KeyCode.UP)) {
                Platform.runLater(() -> {
                    LOG.debug("up - vvalue = {}", spText.getVvalue());
                    spText.setVvalue(spText.getVvalue() - spText.getVmax() / 10);
                });
            }
        });
        final Thread t = new Thread() {
            @Override
            public void run() {
                runEyeTracker();
            }
        };
        t.setDaemon(true);
        t.start();

        scrollExist = true;
    }
    LOG.info("addScrollTracker() - end;");
}

From source file:com.bekwam.resignator.JarsignerConfigController.java

@FXML
public void initialize() {

    if (logger.isDebugEnabled()) {
        logger.debug("[INIT] instance={}, configurationDS={}", this.hashCode(), configurationDS.hashCode());
    }//  ww  w . ja  v a2s .co  m

    cbVerbose.getItems().addAll(Boolean.TRUE, Boolean.FALSE);

    pfStorepass.textProperty().bindBidirectional(activeProfile.jarsignerConfigStorepassProperty());
    tfKeystore.textProperty().bindBidirectional(activeProfile.jarsignerConfigKeystoreProperty());
    pfKeypass.textProperty().bindBidirectional(activeProfile.jarsignerConfigKeypassProperty());
    cbVerbose.valueProperty().bindBidirectional(activeProfile.jarsignerConfigVerboseProperty());

    lblConfKeypass.setVisible(false);
    lblConfStorepass.setVisible(false);
    lblKeystoreNotFound.setVisible(false);

    //
    // Enables ChoiceBox controls to use the arrow keys without losing focus
    //
    vbox.addEventFilter(KeyEvent.KEY_PRESSED, (evt) -> {
        if (evt.getCode() == KeyCode.UP || evt.getCode() == KeyCode.DOWN) {
            evt.consume();
        }
    });

    //
    // #7 fire action event when tfs lose focus
    //
    InvalidationListener pfConfStorepassListener = (evt) -> {
        if (!pfConfStorepass.isFocused()) {
            verifyStorepass();
        }
    };

    pfConfStorepass.focusedProperty().addListener(new WeakInvalidationListener(pfConfStorepassListener));

    InvalidationListener pfConfKeypassListener = (evt) -> {
        if (!pfConfKeypass.isFocused()) {
            verifyKeypass();
        }
    };

    pfConfKeypass.focusedProperty().addListener(new WeakInvalidationListener(pfConfKeypassListener));

    tfKeystore.textProperty().addListener(new WeakInvalidationListener(needsSaveListener));
    pfStorepass.textProperty().addListener(new WeakInvalidationListener(needsSaveListener));
    pfKeypass.textProperty().addListener(new WeakInvalidationListener(needsSaveListener));
    cbAlias.valueProperty().addListener(new WeakInvalidationListener(needsSaveListener));
}

From source file:com.hengyi.japp.print.client.controller.MdController.java

@FXML
private void autoCompleteSapMara(KeyEvent ev) {
    try {/*from  w w  w  .  jav  a2 s. com*/
        if (KeyCode.RIGHT.equals(ev.getCode())) {
            List<SapMara> sapMaras = md.getSapT001().autoCompleteSapMara(matnrField.getText());
            sapMaraListView.setItems(observableArrayList(sapMaras));
            sapMaraListView.setVisible(true);
            sapMaraListView.getSelectionModel().selectFirst();
        } else if (KeyCode.UP.equals(ev.getCode()) || KeyCode.DOWN.equals(ev.getCode())) {
            sapMaraListView.fireEvent(new KeyEvent(null, sapMaraListView, KeyEvent.KEY_PRESSED,
                    ev.getCharacter(), ev.getText(), ev.getCode(), false, false, false, false));
        } else if (KeyCode.ENTER.equals(ev.getCode())) {
            selectSapMara(sapMaraListView.getSelectionModel().getSelectedItem());
            sapMaraListView.setVisible(false);
        }
    } catch (Exception ex) {
        Util.alertDialog(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)/*w  w  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:com.properned.application.SystemController.java

public void initialize() {
    logger.info("Initialize System controller");
    localeButton.disableProperty().bind(multiLanguageProperties.isLoadedProperty().not());
    saveButton.disableProperty().bind(multiLanguageProperties.isDirtyProperty().not()
            .or(multiLanguageProperties.isLoadedProperty().not()));
    Stage primaryStage = Properned.getInstance().getPrimaryStage();
    primaryStage.titleProperty()//from   w  ww.  ja va  2 s. c o  m
            .bind(multiLanguageProperties.baseNameProperty()
                    .concat(Bindings.when(multiLanguageProperties.isLoadedProperty())
                            .then(new SimpleStringProperty(" (")
                                    .concat(multiLanguageProperties.parentDirectoryPathProperty()).concat(")"))
                            .otherwise(""))
                    .concat(Bindings.when(multiLanguageProperties.isDirtyProperty()).then(" *").otherwise("")));

    FilteredList<String> filteredList = new FilteredList<>(multiLanguageProperties.getListMessageKey(),
            new Predicate<String>() {
                @Override
                public boolean test(String t) {
                    String filter = filterText.getText();
                    if (filter == null || filter.equals("")) {
                        return true;
                    }
                    return t.contains(filter);
                }
            });
    SortedList<String> sortedList = new SortedList<>(filteredList, new Comparator<String>() {
        @Override
        public int compare(String o1, String o2) {
            return o1.compareTo(o2);
        }
    });
    messageKeyList.setItems(sortedList);
    filterText.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            // Filter the list
            filteredList.setPredicate(new Predicate<String>() {
                @Override
                public boolean test(String t) {
                    String filter = filterText.getText();
                    if (filter == null || filter.equals("")) {
                        return true;
                    }
                    return t.contains(filter);
                }
            });

            // check the add button disabled status
            if (isKeyCanBeAdded(newValue)) {
                addButton.setDisable(false);
            } else {
                addButton.setDisable(true);
            }

        }

    });
    ChangeListener<String> changeMessageListener = new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            logger.info("Message key selection changed : " + newValue);
            valueList.setItems(FXCollections.observableArrayList());

            valueList.setItems(FXCollections
                    .observableArrayList(multiLanguageProperties.getMapPropertiesByLocale().keySet()));
        }
    };
    messageKeyList.getSelectionModel().selectedItemProperty().addListener(changeMessageListener);
    messageKeyList.setCellFactory(c -> new MessageKeyListCell(multiLanguageProperties));

    valueList.setCellFactory(c -> new ValueListCell(multiLanguageProperties, messageKeyList));

    filterText.setOnKeyReleased(new EventHandler<KeyEvent>() {
        @Override
        public void handle(KeyEvent event) {
            if (event.getCode() == KeyCode.DOWN) {
                messageKeyList.requestFocus();
                event.consume();
            } else if (event.getCode() == KeyCode.ENTER) {
                addKey();
                event.consume();
            }
        }
    });
}

From source file:jobhunter.gui.FXMLController.java

@FXML
void subscriptionTableKey(KeyEvent e) {
    if (e.getCode() == KeyCode.UP || e.getCode() == KeyCode.DOWN)
        subscriptionTableClick(null);
}

From source file:jobhunter.gui.FXMLController.java

@FXML
void jobsListKey(KeyEvent e) {
    if (e.getCode() == KeyCode.UP || e.getCode() == KeyCode.DOWN)
        jobsListClick(null);
}

From source file:com.cdd.bao.editor.EditSchema.java

private void createMenuItems() {
    final KeyCombination.Modifier cmd = KeyCombination.SHORTCUT_DOWN, shift = KeyCombination.SHIFT_DOWN,
            alt = KeyCombination.ALT_DOWN;

    addMenu(menuFile, "_New", new KeyCharacterCombination("N", cmd)).setOnAction(event -> actionFileNew());
    addMenu(menuFile, "_Open", new KeyCharacterCombination("O", cmd)).setOnAction(event -> actionFileOpen());
    addMenu(menuFile, "_Save", new KeyCharacterCombination("S", cmd))
            .setOnAction(event -> actionFileSave(false));
    addMenu(menuFile, "Save _As", new KeyCharacterCombination("S", cmd, shift))
            .setOnAction(event -> actionFileSave(true));
    addMenu(menuFile, "_Export Dump", new KeyCharacterCombination("E", cmd))
            .setOnAction(event -> actionFileExportDump());
    addMenu(menuFile, "_Merge", null).setOnAction(event -> actionFileMerge());
    menuFile.getItems().add(new SeparatorMenuItem());
    addMenu(menuFile, "Confi_gure", new KeyCharacterCombination(",", cmd))
            .setOnAction(event -> actionFileConfigure());
    addMenu(menuFile, "_Browse Endpoint", new KeyCharacterCombination("B", cmd, shift))
            .setOnAction(event -> actionFileBrowse());
    if (false) {/*www .  ja va2  s.  co  m*/
        addMenu(menuFile, "_Upload Endpoint", new KeyCharacterCombination("U", cmd, shift))
                .setOnAction(event -> actionFileUpload());
    }
    Menu menuFileGraphics = new Menu("Graphics");
    addMenu(menuFileGraphics, "_Template", null).setOnAction(event -> actionFileGraphicsTemplate());
    addMenu(menuFileGraphics, "_Assay", null).setOnAction(event -> actionFileGraphicsAssay());
    addMenu(menuFileGraphics, "_Properties", null).setOnAction(event -> actionFileGraphicsProperties());
    addMenu(menuFileGraphics, "_Values", null).setOnAction(event -> actionFileGraphicsValues());
    menuFile.getItems().add(menuFileGraphics);
    addMenu(menuFile, "Assay Stats", null).setOnAction(event -> actionFileAssayStats());
    menuFile.getItems().add(new SeparatorMenuItem());
    addMenu(menuFile, "_Close", new KeyCharacterCombination("W", cmd)).setOnAction(event -> actionFileClose());
    addMenu(menuFile, "_Quit", new KeyCharacterCombination("Q", cmd)).setOnAction(event -> actionFileQuit());

    addMenu(menuEdit, "Add _Group", new KeyCharacterCombination("G", cmd, shift))
            .setOnAction(event -> actionGroupAdd());
    addMenu(menuEdit, "Add _Assignment", new KeyCharacterCombination("A", cmd, shift))
            .setOnAction(event -> actionAssignmentAdd());
    addMenu(menuEdit, "Add Assa_y", new KeyCharacterCombination("Y", cmd, shift))
            .setOnAction(event -> actionAssayAdd());
    menuEdit.getItems().add(new SeparatorMenuItem());
    addMenu(menuEdit, "Cu_t", new KeyCharacterCombination("X", cmd)).setOnAction(event -> actionEditCopy(true));
    addMenu(menuEdit, "_Copy", new KeyCharacterCombination("C", cmd))
            .setOnAction(event -> actionEditCopy(false));
    Menu menuCopyAs = new Menu("Copy As");
    menuEdit.getItems().add(menuCopyAs);
    addMenu(menuEdit, "_Paste", new KeyCharacterCombination("V", cmd)).setOnAction(event -> actionEditPaste());
    menuEdit.getItems().add(new SeparatorMenuItem());
    addMenu(menuEdit, "_Delete", new KeyCodeCombination(KeyCode.DELETE, cmd, shift))
            .setOnAction(event -> actionEditDelete());
    addMenu(menuEdit, "_Undo", new KeyCharacterCombination("Z", cmd, shift))
            .setOnAction(event -> actionEditUndo());
    addMenu(menuEdit, "_Redo", new KeyCharacterCombination("Z", cmd, shift, alt))
            .setOnAction(event -> actionEditRedo());
    menuEdit.getItems().add(new SeparatorMenuItem());
    addMenu(menuEdit, "Move _Up", new KeyCharacterCombination("[", cmd))
            .setOnAction(event -> actionEditMove(-1));
    addMenu(menuEdit, "Move _Down", new KeyCharacterCombination("]", cmd))
            .setOnAction(event -> actionEditMove(1));

    addMenu(menuCopyAs, "Layout Tab-Separated", null).setOnAction(event -> actionEditCopyLayoutTSV());

    addMenu(menuValue, "_Add Value", new KeyCharacterCombination("V", cmd, shift))
            .setOnAction(event -> detail.actionValueAdd());
    addMenu(menuValue, "Add _Multiple Values", new KeyCharacterCombination("M", cmd, shift))
            .setOnAction(event -> detail.actionValueMultiAdd());
    addMenu(menuValue, "_Delete Value", new KeyCodeCombination(KeyCode.DELETE, cmd))
            .setOnAction(event -> detail.actionValueDelete());
    addMenu(menuValue, "Move _Up", new KeyCodeCombination(KeyCode.UP, cmd))
            .setOnAction(event -> detail.actionValueMove(-1));
    addMenu(menuValue, "Move _Down", new KeyCodeCombination(KeyCode.DOWN, cmd))
            .setOnAction(event -> detail.actionValueMove(1));
    menuValue.getItems().add(new SeparatorMenuItem());
    addMenu(menuValue, "_Lookup URI", new KeyCharacterCombination("U", cmd))
            .setOnAction(event -> detail.actionLookupURI());
    addMenu(menuValue, "Lookup _Name", new KeyCharacterCombination("L", cmd))
            .setOnAction(event -> detail.actionLookupName());
    menuValue.getItems().add(new SeparatorMenuItem());
    addMenu(menuValue, "_Sort Values", null).setOnAction(event -> actionValueSort());
    addMenu(menuValue, "_Remove Duplicates", null).setOnAction(event -> actionValueDuplicates());
    addMenu(menuValue, "Cleanup Values", null).setOnAction(event -> actionValueCleanup());

    (menuViewSummary = addCheckMenu(menuView, "_Summary Values", new KeyCharacterCombination("-", cmd)))
            .setOnAction(event -> actionViewToggleSummary());
    addMenu(menuView, "_Template", new KeyCharacterCombination("1", cmd))
            .setOnAction(event -> actionViewTemplate());
    addMenu(menuView, "_Assays", new KeyCharacterCombination("2", cmd))
            .setOnAction(event -> actionViewAssays());
    addMenu(menuView, "_Derived Tree", new KeyCharacterCombination("3", cmd))
            .setOnAction(event -> detail.actionShowTree());
}