Java 类javafx.scene.input.KeyCode 实例源码

项目:AlphaLab    文件:FrmSolicitarReservaHorarioPorRequisito.java   
@FXML
void txtNomeSoftware_onKeyPressed(KeyEvent event) {
    if (event.getCode() == KeyCode.ENTER) {
        if (txtNomeSoftware.getText().equals("")) {
            preencherTableViewRequisitos(software.buscarTodosSoftwares());
        } else {
            preencherTableViewRequisitos(software.buscarPorNome(txtNomeSoftware.getText()));
        }
    }
}
项目:Squid    文件:IsotopesManagerController.java   
private void createTextField() {
    textField = new TextField(getString());
    textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
    textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> arg0,
                Boolean arg1, Boolean arg2) {
            if (!arg2) {
                commitEdit(textField.getText());
            }
        }
    });

    textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
        @Override
        public void handle(KeyEvent ke) {
            KeyCode kc = ke.getCode();
            if ((kc.equals(KeyCode.ENTER) || kc.equals(KeyCode.UP) || kc.equals(KeyCode.DOWN) || kc.equals(KeyCode.LEFT) || kc.equals(KeyCode.RIGHT))) {
                commitEdit(textField.getText());
            }
        }
    });
}
项目:jmonkeybuilder    文件:Vector3FPropertyControl.java   
/**
 * Update the vector.
 *
 * @param event the event
 */
@FXThread
protected void updateVector(@Nullable final KeyEvent event) {
    if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return;

    final FloatTextField xField = getXField();
    final float x = xField.getValue();

    final FloatTextField yFiled = getYFiled();
    final float y = yFiled.getValue();

    final FloatTextField zField = getZField();
    final float z = zField.getValue();

    final Vector3f oldValue = getPropertyValue() == null ? Vector3f.ZERO : getPropertyValue();
    final Vector3f newValue = new Vector3f();
    newValue.set(x, y, z);

    changed(newValue, oldValue.clone());
}
项目:EpiStats    文件:EpiStats.java   
public EpiStats(Arguments args) {
    super(args, "EpiStats", "1.6.0");
    initServices(Executors.newSingleThreadExecutor());

    Platform.runLater(() -> {
        initStage(1000, 800, true, ResourceUtil.loadImage("favicon.png"));

        Path dir = getWorkingDirectory();
        setScene(new UserInterface(this, dir.resolve("ui.dat"), new ObjectList(dir.resolve("objects.olist")), new PlayerCache(dir.resolve("cache/")))).show();

        Scene sc = getStage().getScene();
        sc.setOnKeyPressed((e) -> {
            if (e.getCode() == KeyCode.ENTER) {
                Node n = sc.getFocusOwner();
                if (n instanceof Button)
                    ((Button) n).fire();
            }
        });
    });

    checkForUpdate();
}
项目:EC_GroupProj_CSC143    文件:MainWindowController.java   
/**
 * Called when the GUI is created. If we need to do something special to anything in the GUI, we do it in here.
 */
@FXML
public void initialize() {
    //Gives the "reset board" menu option the shortcut of ctrl+r
    resetBoard.setAccelerator(new KeyCodeCombination(KeyCode.R,  KeyCombination.CONTROL_DOWN));
    exit.setAccelerator(new KeyCodeCombination(KeyCode.F4, KeyCombination.ALT_DOWN));
    for (int x = 0; x < boardWidth; x++) {
        for (int y = 0; y < boardHeight; y++) {
            board.add(new FXSpace(), x, y);
        }
    }
    board.setMaxWidth(FXSpace.WIDTH * boardWidth);
    board.setMaxHeight(FXSpace.HEIGHT * boardHeight);
    board.setBorder(new Border(new BorderStroke(Color.LIGHTGREY, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(1))));

    for (int x = 0; x < tileTrayWidth; x++) {
        tileTray.add(new FXSpace(), x, 0);
    }
    tileTray.setMaxWidth(FXSpace.WIDTH * tileTrayWidth);
    tileTray.setMaxHeight(FXSpace.HEIGHT * 1);
    tileTray.setBorder(new Border(new BorderStroke(Color.LIGHTGREY, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(1))));
}
项目:alchem    文件:AddSaleController.java   
public void batchKeyReleaseEvent() {
    batch.getEditor().setOnKeyReleased((KeyEvent keyEvent) -> {
        if (keyEvent.getCode().isLetterKey() || keyEvent.getCode().isDigitKey() || keyEvent.getCode() == KeyCode.BACK_SPACE) {
            String Batch = batch.getEditor().getText();

            ObservableList<String> sorted_batch_list = FXCollections.observableArrayList();
            batch.setItems(sorted_batch_list);

            Iterator it = batch_list.iterator();
            while (it.hasNext()) {
                String batch_item = it.next().toString();
                if (batch_item.contains(Batch)) {
                    sorted_batch_list.add(batch_item);
                }
            }

            if (Batch.equals("")) {
                batch.hide();
                batch.setItems(batch_list);
            } else if (sorted_batch_list.size() == 0) {
                batch.hide();
            } else
                batch.show();
        }
    });
}
项目:fxexperience2    文件:GradientPickerStop.java   
@FXML
void thumbKeyPressed(KeyEvent e) {
    if (e.getCode() == KeyCode.BACK_SPACE || e.getCode() == KeyCode.DELETE) {
        gradientPicker.removeStop(this);
        // Called when removing a gradient stop :
        // - update gradient preview accordingly
        // - update model
        final PaintPickerController paintPicker
                = gradientPicker.getPaintPickerController();
        final Mode mode = paintPicker.getMode();
        final Paint value = gradientPicker.getValue(mode);
        gradientPicker.updatePreview(value);
        // Update model
        paintPicker.setPaintProperty(value);
        e.consume();
    }
}
项目:fx-animation-editor    文件:SaveDialogComponent.java   
private void onKeyPressed(KeyEvent event) {
    if (event.getCode() == KeyCode.ESCAPE) {
        handleSelection(Selection.CANCEL);
    } else if (event.getCode() == KeyCode.ENTER) {
        Node focusOwner = root.getScene().getFocusOwner();
        if (focusOwner instanceof Button) {
            ((Button) (focusOwner)).fire();
        }
    }
}
项目:jmonkeybuilder    文件:QuaternionPropertyControl.java   
/**
 * Updating rotation.
 */
@FXThread
private void updateRotation(@Nullable final KeyEvent event) {
    if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return;

    final Quaternion oldValue = notNull(getPropertyValue());

    final FloatTextField xField = getXField();
    final float x = degreeToRadians(xField.getValue());

    final FloatTextField yFiled = getYFiled();
    final float y = degreeToRadians(yFiled.getValue());

    final FloatTextField zField = getZField();
    final float z = degreeToRadians(zField.getValue());

    final Quaternion newValue = new Quaternion();
    newValue.fromAngles(ArrayFactory.toFloatArray(x, y, z));

    changed(newValue, oldValue.clone());
}
项目:marathonv5    文件:FXEventQueueDevice.java   
@SuppressWarnings("deprecation") public int getModifierEx() {
    int modifiersEx = 0;
    if (shiftPressed) {
        modifiersEx |= KeyCode.SHIFT.impl_getCode();
    }
    if (ctrlPressed) {
        modifiersEx |= KeyCode.CONTROL.impl_getCode();
    }
    if (altPressed) {
        modifiersEx |= KeyCode.ALT.impl_getCode();
    }
    if (metaPressed) {
        modifiersEx |= KeyCode.META.impl_getCode();
    }
    return modifiersEx;
}
项目:marathonv5    文件:EventQueueDeviceKBTest.java   
public void testPressAndReleaseKeys_withAlt() {
    kss.clear();
    driver.pressKey(textField, JavaAgentKeys.ALT);
    driver.pressKey(textField, JavaAgentKeys.F1);
    driver.releaseKey(textField, JavaAgentKeys.F1);
    driver.releaseKey(textField, JavaAgentKeys.ALT);
    List<String> list = Arrays.asList("Alt pressed " + KeyCode.getKeyCode("Alt"), "Alt pressed " + KeyCode.getKeyCode("F1"),
            "Alt released " + KeyCode.getKeyCode("F1"), "released " + KeyCode.getKeyCode("Alt"));
    final String expected = list.toString();
    new WaitWithoutException() {
        @Override public boolean until() {
            return expected.equals(kss.toString());
        }
    }.wait("List is empty", 3000, 500);
    AssertJUnit.assertEquals(expected, kss.toString());
}
项目:FYS_T3    文件:homepageController.java   
@FXML
public void openStatisticsAction(ActionEvent event) throws IOException {
    Node node = (Node) event.getSource();
    final Stage stage = (Stage) node.getScene().getWindow();
    Parent root = FXMLLoader.load(getClass().getResource("/fxml/Statistics.fxml"));
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();

    final Parent home = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml"));
    final Scene hScene = new Scene(home);
    root.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            if (ke.getCode() == KeyCode.ESCAPE) {
                System.out.println("Key Pressed: " + ke.getCode());
                stage.setScene(hScene);
            }
        }
    });
}
项目:ETUmulator    文件:Thumb2CodeArea.java   
public Thumb2CodeArea() {
    getStylesheets().clear();
    getStylesheets().add(Thumb2CodeArea.class.getClassLoader()
            .getResource("styles/thumb2-syntax-highlight.css").toExternalForm());
    getStylesheets().add(Thumb2CodeArea.class.getClassLoader()
            .getResource("styles/spellchecking.css").toExternalForm());
    setCursor(Cursor.TEXT);
    richChanges().filter(ch -> !ch.getInserted().equals(ch.getRemoved()))
            .subscribe(change -> {
                SyntaxHighlighter syntaxHighlighter = new SyntaxHighlighter();
                setStyleSpans(0, syntaxHighlighter.highlight(getText()));
            });
    addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent e) -> {
        if(e.getCode() == KeyCode.TAB) {
            String s = "    ";
            insertText(getCaretPosition(), s);
            e.consume();
        }
    });
}
项目:FYS_T3    文件:contactController.java   
@FXML
public void openSubmitAction(ActionEvent event) throws IOException {
    Node node = (Node) event.getSource();
    final Stage stage = (Stage) node.getScene().getWindow();

    Parent root = FXMLLoader.load(getClass().getResource("/fxml/Submit.fxml"));
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();

    final Parent home = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml"));
    final Scene hScene = new Scene(home);
    root.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            if (ke.getCode() == KeyCode.ESCAPE) {
                System.out.println("Key Pressed: " + ke.getCode());
                stage.setScene(hScene);
            }
        }
    });
}
项目:Sifon-Industries    文件:Calc.java   
@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

    Scene scene = new Scene(root);


    stage.setScene(scene);
    stage.getIcons().add(new Image("/icon.png"));
    stage.show();
    stage.setMinWidth(stage.getWidth());
    stage.setMinHeight(stage.getHeight());

    scene.setOnKeyPressed(e -> {
        if (e.getCode() == KeyCode.NUMPAD1 || e.getCode() == KeyCode.DIGIT1) {
            controller.keyPressed('1');
        }else if (e.getCode() == KeyCode.NUMPAD2 || e.getCode() == KeyCode.DIGIT2) {
            controller.keyPressed('2');
        }else if (e.getCode() == KeyCode.NUMPAD3 || e.getCode() == KeyCode.DIGIT3) {
            controller.keyPressed('3');
        }else if (e.getCode() == KeyCode.NUMPAD4 || e.getCode() == KeyCode.DIGIT4) {
            controller.keyPressed('4');
        }else if (e.getCode() == KeyCode.NUMPAD5 || e.getCode() == KeyCode.DIGIT5) {
            controller.keyPressed('5');
        }else if (e.getCode() == KeyCode.NUMPAD6 || e.getCode() == KeyCode.DIGIT6) {
            controller.keyPressed('6');
        }else if (e.getCode() == KeyCode.NUMPAD7 || e.getCode() == KeyCode.DIGIT7) {
            controller.keyPressed('7');
        }else if (e.getCode() == KeyCode.NUMPAD8 || e.getCode() == KeyCode.DIGIT8) {
            controller.keyPressed('8');
        }else if (e.getCode() == KeyCode.NUMPAD9 || e.getCode() == KeyCode.DIGIT9) {
            controller.keyPressed('9');
        }else if (e.getCode() == KeyCode.NUMPAD0 || e.getCode() == KeyCode.DIGIT0) {
            controller.keyPressed('0');
        }else if (e.getCode() == KeyCode.ADD || e.getCode() == KeyCode.PLUS) {
            controller.keyPressed('+');
        }else if (e.getCode() == KeyCode.SUBTRACT || e.getCode() == KeyCode.MINUS) {
            controller.keyPressed('-');
        }else if (e.getCode() == KeyCode.MULTIPLY) {
            controller.keyPressed('*');
        }else if (e.getCode() == KeyCode.DIVIDE || e.getCode() == KeyCode.SLASH) {
            controller.keyPressed('/');
        }else if (e.getCode() == KeyCode.ENTER || e.getCode() == KeyCode.EQUALS) {
            controller.keyPressed('=');
        }else if (e.getCode() == KeyCode.PERIOD || e.getCode() == KeyCode.COMMA || e.getCode() == KeyCode.DECIMAL) {
            controller.keyPressed('.');
        }else if (e.getCode() == KeyCode.BACK_SPACE) {
            controller.keyPressed('b');
        }else if (e.getCode() == KeyCode.ESCAPE || e.getCode() == KeyCode.DELETE) {
            controller.keyPressed('c');
        }
    });
}
项目:CSLMusicModStationCreator    文件:ConjunctionEditor.java   
@FXML
private void initialize() {
    content.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    addEntry.showingProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean t1) {
            rebuildAddItemMenu();
        }
    });

    content.setOnKeyPressed(keyEvent -> {
        if(keyEvent.getCode() == KeyCode.DELETE) {
            removeEntries();
        }
    });
}
项目:CSLMusicModStationCreator    文件:ContextEntryEditor.java   
@FXML
private void initialize() {

    songs.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    contextCollections.getCheckModel().getCheckedItems().addListener(new ListChangeListener<String>() {
        @Override
        public void onChanged(Change<? extends String> change) {
            updateSongsAutoComplete();
        }
    });
    songs.setOnKeyPressed(keyEvent -> {
        if(keyEvent.getCode() == KeyCode.DELETE) {
            removeSongs();
        }
    });
}
项目:stvs    文件:AdvancedCellUtils.java   
static <T> TextField createTextField(final Cell<T> cell, final StringConverter<T> converter) {
    final TextField textField = new TextField(getItemText(cell, converter));

    // Use onAction here rather than onKeyReleased (with check for Enter),
    // as otherwise we encounter RT-34685
    textField.setOnAction(event -> {
        if (converter == null) {
            throw new IllegalStateException(
                    "Attempting to convert text input into Object, but provided "
                            + "StringConverter is null. Be sure to set a StringConverter "
                            + "in your cell factory.");
        }
        cell.commitEdit(converter.fromString(textField.getText()));
        event.consume();
    });
    textField.setOnKeyReleased(t -> {
        if (t.getCode() == KeyCode.ESCAPE) {
            cell.cancelEdit();
            t.consume();
        }
    });
    return textField;
}
项目:FYS_T3    文件:submitController.java   
@FXML
public void openSubmitAction(ActionEvent event) throws IOException {
    Node node = (Node) event.getSource();
    final Stage stage = (Stage) node.getScene().getWindow();
    final Parent home = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml"));
    final Scene hScene = new Scene(home);
    Parent root = FXMLLoader.load(getClass().getResource("/fxml/Submit.fxml"));
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();

    root.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            if (ke.getCode() == KeyCode.ESCAPE) {
                System.out.println("Key Pressed: " + ke.getCode());
                stage.setScene(hScene);
            }
        }
    });
}
项目:qupath-tracking-extension    文件:QuPathTrackingExtension.java   
public void installExtension(QuPathGUI qupath) {
    initDefaultViewTrackerFactory(qupath.getViewer());

    if (System.getProperty("os.name").toLowerCase().contains("linux")) {
        DisplayHelpers.showInfoNotification("Tracking extension issue reporting",
                "Bug reports and feature requests can be logged at:\n" +
                "http://github.com/Alanocallaghan/qupath-tracking-extension");
    } else {
        QuPathGUI.addMenuItems(
                qupath.getMenu("Extensions>Tracking", true),
                QuPathGUI.createCommandAction(
                        new OpenWebpageCommand(qupath,
                                "http://github.com/Alanocallaghan/qupath-tracking-extension/issues"),
                        "Bug reports/issues")
        );
    }

    QuPathGUI.addMenuItems(
            qupath.getMenu("Extensions>Tracking", true),
            QuPathGUI.createCommandAction(new TrackingQuPathLoadCommand(), "Tracking extension"),
            new KeyCodeCombination(KeyCode.T, KeyCombination.CONTROL_DOWN)
            );

       // TODO: Use md5 sum to tie tracking instance to image (using MessageDigest) http://stackoverflow.com/questions/4187111/how-to-get-the-md5sum-of-a-file-in-java

}
项目:CSS-Editor-FX    文件:OptionsController.java   
private String convert(KeyEvent e) {
  return TaskUtil.firstSuccess(
      () -> new KeyCodeCombination(e.getCode(),
          e.isShiftDown() ? ModifierValue.DOWN : ModifierValue.UP,
          e.isControlDown() ? ModifierValue.DOWN : ModifierValue.UP,
          e.isAltDown() ? ModifierValue.DOWN : ModifierValue.UP,
          e.isMetaDown() ? ModifierValue.DOWN : ModifierValue.UP,
          ModifierValue.UP).toString(),
      () -> {
        KeyCodeCombination key = new KeyCodeCombination(KeyCode.A,
            e.isShiftDown() ? ModifierValue.DOWN : ModifierValue.UP,
            e.isControlDown() ? ModifierValue.DOWN : ModifierValue.UP,
            e.isAltDown() ? ModifierValue.DOWN : ModifierValue.UP,
            e.isMetaDown() ? ModifierValue.DOWN : ModifierValue.UP,
            ModifierValue.UP);
        String name = key.getName();
        return name.substring(0, name.length() - key.getCode().getName().length());
      });
}
项目:uPMT    文件:InterviewTreeViewController.java   
public void renameInter(){
    renameInterview.setDisable(true);
    TextField textField = new TextField();
    textField.setText(interview.getNom());
    textField.setMaxWidth(100);
    textField.requestFocus();
    textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
         @Override
            public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue)
            {
                if (!newPropertyValue)
                {
                    nomEntretien.setText(textField.getText());
                    interview.setNom(textField.getText());
                    interviewPane.setLeft(nomEntretien);
                    renameInterview.setDisable(false);
                }
            }
    });
    textField.setOnKeyPressed(new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent event) {
            if(event.getCode() == KeyCode.ENTER){
                nomEntretien.setText(textField.getText());
                interview.setNom(textField.getText());
                interviewPane.setLeft(nomEntretien);
                renameInterview.setDisable(true);
            }
            if(event.getCode() == KeyCode.ESCAPE){
                interviewPane.setLeft(nomEntretien);
                renameInterview.setDisable(true);
            }
        }
    });
    interviewPane.setLeft(textField);
    Platform.runLater(()->textField.requestFocus());
    Platform.runLater(()->textField.selectAll());

}
项目:FYS_T3    文件:contactController.java   
@FXML
public void openFAQ(final ActionEvent event) throws IOException {
    Node node = (Node) event.getSource();
    final Stage stage = (Stage) node.getScene().getWindow();
    final Parent root = FXMLLoader.load(getClass().getResource("/fxml/FAQ.fxml"));
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();

    final Parent home = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml"));
    final Scene hScene = new Scene(home);
    root.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            if (ke.getCode() == KeyCode.ESCAPE) {
                System.out.println("Key Pressed: " + ke.getCode());
                stage.setScene(hScene);
            }
        }
    });
}
项目:jmonkeybuilder    文件:AbstractSceneEditor3DState.java   
@Override
@JMEThread
protected void registerActionHandlers(@NotNull final ObjectDictionary<String, BooleanFloatConsumer> actionHandlers) {
    super.registerActionHandlers(actionHandlers);

    final T fileEditor = getFileEditor();

    actionHandlers.put(KEY_S, (isPressed, tpf) ->
            fileEditor.handleKeyAction(KeyCode.S, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown()));

    actionHandlers.put(KEY_G, (isPressed, tpf) ->
            fileEditor.handleKeyAction(KeyCode.G, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown()));

    actionHandlers.put(KEY_R, (isPressed, tpf) ->
            fileEditor.handleKeyAction(KeyCode.R, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown()));

    actionHandlers.put(KEY_DEL, (isPressed, tpf) ->
            fileEditor.handleKeyAction(KeyCode.DELETE, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown()));
}
项目:jmonkeybuilder    文件:BaseMaterialEditor3DState.java   
@Override
@JMEThread
protected void registerActionHandlers(@NotNull final ObjectDictionary<String, BooleanFloatConsumer> actionHandlers) {
    super.registerActionHandlers(actionHandlers);

    final T fileEditor = getFileEditor();

    actionHandlers.put(KEY_S, (isPressed, tpf) ->
            fileEditor.handleKeyAction(KeyCode.S, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown()));

    actionHandlers.put(KEY_C, (isPressed, tpf) ->
            fileEditor.handleKeyAction(KeyCode.C, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown()));

    actionHandlers.put(KEY_P, (isPressed, tpf) ->
            fileEditor.handleKeyAction(KeyCode.P, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown()));

    actionHandlers.put(KEY_L, (isPressed, tpf) ->
            fileEditor.handleKeyAction(KeyCode.L, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown()));
}
项目:ABC-List    文件:CellUtils.java   
static <T> TextField createTextField(final Cell<T> cell, final StringConverter<T> converter) {
    final TextField textField = new TextField(getItemText(cell, converter));

    // Use onAction here rather than onKeyReleased (with check for Enter),
    // as otherwise we encounter RT-34685
    textField.setOnAction(event -> {
        if (converter == null) {
            throw new IllegalStateException(
                    "Attempting to convert text input into Object, but provided "
                    + "StringConverter is null. Be sure to set a StringConverter "
                    + "in your cell factory.");
        }
        cell.commitEdit(converter.fromString(textField.getText()));
        event.consume();
    });
    textField.setOnKeyReleased(t -> {
        if (t.getCode() == KeyCode.ESCAPE) {
            cell.cancelEdit();
            t.consume();
        }
    });
    return textField;
}
项目:voogasalad-ltub    文件:TestTriggers.java   
private Trigger gameSave() {
    TriggerEvent triggerEvent = TriggerEvent.createGameTriggerEvent(KeyEvent.PRESS);
    TriggerAction triggerAction = TriggerAction.createGameTriggerAction(
            new GameSaveEvent());
    Trigger trigger = new Trigger(triggerEvent);
    trigger.addAction(triggerAction);
    trigger.addCondition((models, event) -> {
        if (event instanceof KeyEvent) {
            return ((KeyEvent) event).getCode().equals(KeyCode.S);
        } else {
            return false;
        }
    });
    return trigger;
}
项目:jrfl    文件:JrflTextField.java   
public JrflTextField() {
    super("textfield");
    Console console = Console.getConsole();
    n.addEventFilter(KeyEvent.KEY_PRESSED, e -> {
        if(e.getCode() == KeyCode.TAB) e.consume();
    });
    n.setAlignment(Pos.CENTER_LEFT);
    n.setStyle(n.getStyle() + "-fx-background-color: transparent;");

    n.setOnKeyReleased(e -> {
        if(e.getCode() == KeyCode.ENTER) {
            if(!n.getText().replace(" ", "").equals("")) {
                Events.getManager().callEvent(new WriteEvent(n.getText()));
                console.dispatchCommand(n.getText());
                n.setText("");
            }
        }
        else if(e.getCode() == KeyCode.UP) {
            console.switchCommandUp();
        }
        else if(e.getCode() == KeyCode.DOWN) {
            console.switchCommandDown();
        }
        else if(e.getCode() == KeyCode.ESCAPE) {
            n.setText("");
        }
    });
}
项目:AlphaLab    文件:FrmPedidosReserva.java   
@FXML
void tblPedidos_onKeyPressed(KeyEvent event) {
    if (event.getCode() == KeyCode.ENTER) {
        if (tblPedidos.getSelectionModel().getSelectedItem() != null) {
            preencherVisualizarDados(tblPedidos.getSelectionModel().getSelectedItem());
            tbpDados.getSelectionModel().select(tabDados);
        }
    }
}
项目:HueSense    文件:UIUtils.java   
public static void setTextFieldNumbersOnly(TextField field, int min, int max) {
    field.addEventFilter(KeyEvent.KEY_TYPED, (e) -> {

        if (e.getCharacter().matches("[0-9]")) {
            String text = field.getText();
            if (e.getCode() == KeyCode.BACK_SPACE && text.length() > 0) {
                text = text.substring(0, text.length() - 2);
            } else {
                text = text + e.getCharacter();
            }
            try {
                long value = Long.parseLong(text);
                if (value < min) {
                    e.consume();
                    field.setText(String.valueOf(min));
                } else if (value > max) {
                    e.consume();
                    field.setText(String.valueOf(max));
                }
            } catch (NumberFormatException ex) {
                e.consume();
            }
        } else {
            e.consume();
        }
    });
}
项目:Lernkartei_2017    文件:Alert.java   
/**
 * Fenster mit OK- und Abbrechen-Buttons
 * 
 * @param title
 *            Der Titel des Fensters
 * @param message
 *            Die Narchricht, die angezeigt wird. Text wird nicht von selbst
 *            gewrapt.
 * @return True, wenn der User akzeptiert, sonst false
 */
public static boolean ok (String title, String message)
{
    Stage window = buildWindow(title);
    Label l = new Label(message);

    Button bo = new Button("_OK");
    Button ba = new Button("_Abbrechen");

    bo.setOnAction(e ->
    {
        tempOkay = true;
        window.close();
    });

    ba.setOnAction(e ->
    {
        tempOkay = false;
        window.close();
    });

    HBox buttons = new HBox(20);
    buttons.setAlignment(Pos.CENTER);
    buttons.setPadding(new Insets(20));
    buttons.getChildren().addAll(bo, ba);

    VBox layout = new VBox(20);
    layout.getChildren().addAll(l, buttons);
    layout.setAlignment(Pos.CENTER);
    layout.setPadding(new Insets(40, 20, 20, 20));

    int width;
    int x = 6;
    int y = 150;

    width = message.length() * x + y;

    layout.setOnKeyReleased(e ->
    {
        if (e.getCode() == KeyCode.ESCAPE)
            window.close();
    });

    window.setScene(new Scene(layout, width, 150));
    window.showAndWait();

    okay = tempOkay;
    tempOkay = false;

    return okay;
}
项目:infxnity    文件:MaskTextFilterTest.java   
@Override
public void init() throws Exception
{
    release(KeyCode.SHIFT);
    release(KeyCode.CONTROL);
    release(KeyCode.ALT);
    release(KeyCode.ALT_GRAPH);

    super.init();
}
项目:jmonkeybuilder    文件:AbstractFileEditor.java   
/**
 * Handle the key pressed event.
 *
 * @param event the event
 */
@FXThread
protected void processKeyPressed(@NotNull final KeyEvent event) {

    final KeyCode code = event.getCode();

    if (code == KeyCode.S && event.isControlDown() && isDirty()) {
        save();
    } else if (handleKeyActionImpl(code, true, event.isControlDown(), event.isShiftDown(), false)) {
        event.consume();
    }
}
项目:hygene    文件:ConsoleController.java   
/**
 * Handle the user's console input; one {@link KeyEvent} at the time.
 *
 * @param keyEvent the {@link KeyEvent}
 */
public void handleInput(final KeyEvent keyEvent) {
    if (keyEvent.getCode().equals(KeyCode.ENTER)) {
        final String input = consoleInput.getCharacters().toString();

        appendLogItem("> " + input + "\n");

        parseCommand(input);

        consoleInput.clear();
    }
}
项目:WebPLP    文件:CodeEditor.java   
private void initializeEngineEvents()
{
    webView.addEventFilter(KeyEvent.KEY_PRESSED, e -> {
        if( e.isShortcutDown() && e.getCode() == KeyCode.V) 
        {
            String content = (String) Clipboard.getSystemClipboard().getContent(DataFormat.PLAIN_TEXT);
            if (content != null) 
            {
                webView.getEngine().executeScript("editor.onPaste('" + sanitizeForAce(content) + "');");
            }
           }
    });
}
项目:Conan    文件:RowPane.java   
private HotkeyMapper(TextField trigger, ProofView pv, List<RowPane> rList) {
    addFocusListener(trigger, pv);
    trigger.setOnKeyPressed(new EventHandler<KeyEvent>() {
        @Override
        public void handle(KeyEvent key) {
            int index = rList.indexOf(RowPane.this);
            if (ctrlY.match(key) || ctrlShiftZ.match(key)) {
                pv.redo();
                key.consume();
            } else if (ctrlZ.match(key)) {
                pv.undo();
                key.consume();
            } else if (ctrlLeft.match(key)) {
                focusLeft();
            } else if (ctrlRight.match(key)) {
                focusRight();
            } else if (key.getCode() == KeyCode.DOWN) {
                if (index + 1 >= rList.size())
                    pv.addRowAfterBox(index + 1);
                focus(pv, rList, index + 1);
            } else if (key.getCode() == KeyCode.UP) {
                if (index - 1 >= 0) {
                    focus(pv, rList, index - 1);
                } else {
                    pv.insertNewRow(0, BoxReference.AFTER);
                }
            }
        }
    });
}
项目:jmonkeybuilder    文件:AbstractFileEditor.java   
/**
 * Handle the key released event.
 *
 * @param event the event
 */
@FXThread
protected void processKeyReleased(@NotNull final KeyEvent event) {

    final KeyCode code = event.getCode();

    if (handleKeyActionImpl(code, false, event.isControlDown(), event.isShiftDown(), false)) {
        event.consume();
    }
}
项目:marathonv5    文件:ImagePanel.java   
private static TextArea createTextArea(TableCell<Annotation, String> cell) {
    TextArea textArea = new TextArea(cell.getItem() == null ? "" : cell.getItem());
    textArea.setPrefRowCount(1);
    textArea.setWrapText(true);
    textArea.focusedProperty().addListener(new ChangeListener<Boolean>() {
        @Override public void changed(ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2) {
            if (!textArea.isFocused() && cell.getItem() != null && cell.isEditing()) {
                cell.commitEdit(textArea.getText());
            }
            cell.getTableView().getItems().get(cell.getIndex()).setText(textArea.getText());
        }
    });
    textArea.addEventFilter(MouseEvent.MOUSE_CLICKED, (event) -> {
        if (event.getClickCount() > 1) {
            cell.getTableView().edit(cell.getTableRow().getIndex(), cell.getTableColumn());
        } else {
            TableViewSelectionModel<Annotation> selectionModel = cell.getTableView().getSelectionModel();
            if (event.isControlDown()) {
                if (selectionModel.isSelected(cell.getIndex())) {
                    selectionModel.clearSelection(cell.getIndex());
                } else {
                    selectionModel.select(cell.getIndex());
                }
            } else {
                selectionModel.clearAndSelect(cell.getIndex());
            }
        }
    });
    textArea.addEventFilter(KeyEvent.KEY_PRESSED, (event) -> {
        if (event.getCode() == KeyCode.ENTER && event.isShiftDown() && cell.isEditing()) {
            cell.commitEdit(textArea.getText());
            cell.getTableView().getItems().get(cell.getIndex()).setText(textArea.getText());
            event.consume();
        }
        if (event.getCode() == KeyCode.F2) {
            cell.getTableView().edit(cell.getTableRow().getIndex(), cell.getTableColumn());
        }
    });
    return textArea;
}
项目:marathonv5    文件:FXContextMenuTriggers.java   
public static void setContextMenuKey() {
    String keyText = System.getProperty(Constants.PROP_RECORDER_KEYTRIGGER);
    if (keyText == null || keyText.equals("")) {
        contextMenuKey = "F8";
        contextMenuKeyModifiers = OSFXUtils.MOUSE_MENU_MASK;
    } else {
        String downModifierMask = getDownModifierMask(KeyCombination.valueOf(keyText));
        if (downModifierMask.contains("+") && downModifierMask.lastIndexOf("+") == downModifierMask.length() - 1) {
            downModifierMask = downModifierMask.substring(0, downModifierMask.lastIndexOf("+"));
        }
        contextMenuKeyModifiers = downModifierMask;
        String menuKey = keyText.substring(keyText.lastIndexOf('+') + 1);
        contextMenuKey = KeyCode.valueOf(menuKey).getName();
    }
}
项目:marathonv5    文件:ResourceView.java   
private void createTextField() {
    textField = new TextField(getString());
    textField.setOnKeyReleased(new EventHandler<KeyEvent>() {

        @Override public void handle(KeyEvent t) {
            if (t.getCode() == KeyCode.ENTER) {
                Resource value = getTreeItem().getValue();
                File file = new File(((FolderResource) value.getParent()).getFilePath().toFile(), textField.getText());
                if (file.exists()) {
                    FXUIUtils.showMessageDialog(null, "File " + file.getName() + " already exists", null, AlertType.ERROR);
                    cancelEdit();
                    return;
                }
                Resource renamed = value.rename(textField.getText());
                if (renamed != null) {
                    commitEdit(renamed);
                    Resource parent = (Resource) value.getParent();
                    if (parent != null) {
                        int index = parent.getChildren().indexOf(value);
                        parent.getChildren().remove(index);
                        parent.getChildren().add(index, renamed);
                    }
                } else {
                    cancelEdit();
                }
            } else if (t.getCode() == KeyCode.ESCAPE) {
                cancelEdit();
            }
        }
    });
}