类javafx.scene.input.InputEvent源码实例Demo

下面列出了怎么用javafx.scene.input.InputEvent的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: chart-fx   文件: ChartPlugin.java
@SuppressWarnings("unchecked")
private <T extends InputEvent> void addEventHandlers(final Node node) {
    if (node == null) {
        return;
    }
    for (final Pair<EventType<? extends InputEvent>, EventHandler<? extends InputEvent>> pair : mouseEventHandlers) {
        final EventType<T> type = (EventType<T>) pair.getKey();
        final EventHandler<T> handler = (EventHandler<T>) pair.getValue();
        node.addEventHandler(type, handler);
        node.sceneProperty().addListener((ch, o, n) -> {
            if (o == n) {
                return;
            }
            if (o != null) {
                o.removeEventHandler(type, handler);
            }

            if (n != null) {
                n.addEventHandler(type, handler);
            }
        });
    }
}
 
源代码2 项目: dev-tools   文件: MainController.java
@FXML
private void handleKeyInput(final InputEvent event) {
    if (event instanceof KeyEvent) {
        final KeyEvent keyEvent = (KeyEvent) event;
        if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.A) {
            debug("handleKeyInput");
        }
    }
}
 
源代码3 项目: chart-fx   文件: ChartPlugin.java
@SuppressWarnings("unchecked")
private <T extends InputEvent> void removeEventHandlers(final Node node) {
    if (node == null) {
        return;
    }
    for (final Pair<EventType<? extends InputEvent>, EventHandler<? extends InputEvent>> pair : mouseEventHandlers) {
        final EventType<T> type = (EventType<T>) pair.getKey();
        final EventHandler<T> handler = (EventHandler<T>) pair.getValue();
        node.removeEventHandler(type, handler);
        if (node.getScene() != null) {
            node.getScene().removeEventFilter(type, handler);
        }
    }
}
 
源代码4 项目: marathonv5   文件: JavaFxRecorderHook.java
protected void setupSceneRoot(Parent root) {
    root.getProperties().put("marathon.fileChooser.eventType", fileChooserEventType);
    root.getProperties().put("marathon.folderChooser.eventType", folderChooserEventType);
    root.addEventFilter(InputEvent.ANY, JavaFxRecorderHook.this);
    root.addEventFilter(fileChooserEventType, JavaFxRecorderHook.this);
    root.addEventFilter(folderChooserEventType, JavaFxRecorderHook.this);
    root.getProperties().put("marathon.menu.handler", menuEvent);
}
 
源代码5 项目: gef   文件: AllSwtFxEvents.java
@Override
public Scene createScene() {
	Scene scene = new Scene(new Group(), 400, 400);
	scene.addEventFilter(InputEvent.ANY, new EventHandler<InputEvent>() {
		@Override
		public void handle(InputEvent event) {
			System.out.println(event);
		}
	});
	return scene;
}
 
源代码6 项目: gef   文件: AllFxEvents.java
@Override
public Scene createScene() {
	Scene scene = new Scene(new Group(new Rectangle(50, 50)), 400, 400);
	scene.addEventFilter(InputEvent.ANY, new EventHandler<InputEvent>() {
		@Override
		public void handle(InputEvent event) {
			System.out.println(event);
		}
	});
	return scene;
}
 
源代码7 项目: Enzo   文件: TButtonSkin.java
private void init() {
    if (Double.compare(getSkinnable().getPrefWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getPrefHeight(), 0.0) <= 0 ||
        Double.compare(getSkinnable().getWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getHeight(), 0.0) <= 0) {
        if (getSkinnable().getPrefWidth() > 0 && getSkinnable().getPrefHeight() > 0) {
            getSkinnable().setPrefSize(getSkinnable().getPrefWidth(), getSkinnable().getPrefHeight());
        } else {
            getSkinnable().setPrefSize(PREFERRED_SIZE, PREFERRED_SIZE);
        }
    }

    if (Double.compare(getSkinnable().getMinWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getMinHeight(), 0.0) <= 0) {
        getSkinnable().setMinSize(MINIMUM_SIZE, MINIMUM_SIZE);
    }

    if (Double.compare(getSkinnable().getMaxWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getMaxHeight(), 0.0) <= 0) {
        getSkinnable().setMaxSize(MAXIMUM_SIZE, MAXIMUM_SIZE);
    }

    inputHandler = new EventHandler<InputEvent>() {
        @Override public void handle(final InputEvent EVENT) {
            final EventType TYPE = EVENT.getEventType();
            final Object    SRC  = EVENT.getSource();
            if (MouseEvent.MOUSE_PRESSED == TYPE) {
                if (SRC.equals(on)) {
                    getSkinnable().setSelected(false);
                } else if (SRC.equals(off)) {
                    getSkinnable().setSelected(true);
                }
                EVENT.consume();
            }
        }
    };
}
 
源代码8 项目: chart-fx   文件: EditDataSet.java
SelectedDataPoint(final Axis xAxis, final Axis yAxis, final EditableDataSet dataSet, final int index) {
    super();
    getStyleClass().add(STYLE_CLASS_SELECT_PATH);
    // this.setPickOnBounds(true);
    // setManaged(false);

    final EditConstraints constraints = dataSet.getEditConstraints();
    if (constraints == null) {
        pseudoClassStateChanged(NOEDIT_PSEUDO_CLASS, false);
    } else {
        final boolean canChange = constraints.canChange(index);
        if (!canChange) {
            pseudoClassStateChanged(NOEDIT_PSEUDO_CLASS, true);
        }
    }

    this.xAxis = xAxis;
    this.yAxis = yAxis;
    this.dataSet = dataSet;
    this.xValue = dataSet.get(DataSet.DIM_X, index);
    this.yValue = dataSet.get(DataSet.DIM_Y, index);
    this.setCenterX(getX()); // NOPMD by rstein on 13/06/19 14:14
    this.setCenterY(getY()); // NOPMD by rstein on 13/06/19 14:14
    this.setRadius(DEFAULT_MARKER_RADIUS);

    final EventHandler<? super InputEvent> dragOver = e -> {
        // finished drag
        isPointDragActive = false;
        setCursor(Cursor.DEFAULT);
    };

    setOnMouseEntered(e -> setCursor(Cursor.OPEN_HAND));
    addEventFilter(MouseDragEvent.MOUSE_DRAG_OVER, dragOver);

    setOnMousePressed(startDragHandler(this));
    // setOnMouseDragged(dragHandler(this));
    setOnMouseReleased(dragOver);
    setOnMouseDragOver(dragOver);
    // this.setOnMouseExited(dragOver);

    xAxis.addListener(evt -> FXUtils.runFX(() -> this.setCenterX(getX())));
    yAxis.addListener(evt -> FXUtils.runFX(() -> this.setCenterY(getY())));
    dataSet.addListener(e -> FXUtils.runFX(this::update));
}
 
源代码9 项目: marathonv5   文件: JavaFxRecorderHook.java
private void removeEventFilter(Stage stage) {
    stage.getScene().getRoot().removeEventFilter(InputEvent.ANY, JavaFxRecorderHook.this);
    stage.getScene().getRoot().removeEventFilter(fileChooserEventType, JavaFxRecorderHook.this);
    stage.getScene().getRoot().removeEventFilter(folderChooserEventType, JavaFxRecorderHook.this);
}
 
源代码10 项目: CPUSim   文件: EditMicroinstructionsController.java
/**
 * initializes the dialog window after its root element has been processed.
 * contains a listener to the combo box, so that the content of the table will
 * change according to the selected type of microinstruction.
 *
 * @param url the location used to resolve relative paths for the root
 *            object, or null if the location is not known.
 * @param rb  the resources used to localize the root object, or null if the root
 *            object was not localized.
 */
@Override
public void initialize(URL url, ResourceBundle rb) {

    microinstructionCombo.setVisibleRowCount(14); // show all micros at once

    tableMap.setParents(tablePane);
    tablePane.getChildren().clear();
    activeTable = tableMap.getMap().get("TransferRtoR");
    tablePane.getChildren().add(activeTable);

    activeTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    newButton.setDisable(!((MicroController)activeTable).newMicrosAreAllowed());

    activeTable.getSelectionModel().selectedItemProperty().addListener(listener);

    // resizes the width and height of the table to match the dialog
    tablePane.widthProperty().addListener((observableValue, oldValue, newValue) ->
                activeTable.setPrefWidth((Double) newValue)
    );
    tablePane.heightProperty().addListener((observableValue, oldValue, newValue) ->
                activeTable.setPrefHeight((Double)newValue)
    );

    // listen for changes to the instruction combo box selection and update
    // the displayed micro instruction table accordingly.
    microinstructionCombo.getSelectionModel().selectedItemProperty().addListener(
            (selected, oldType, newType) -> {
                activeTable.getSelectionModel().selectedItemProperty().
                        removeListener(listener);
                tableMap.getMap().get(oldType).getSelectionModel().clearSelection();
                tablePane.getChildren().clear();
                tablePane.getChildren().add(
                        tableMap.getMap().get(newType));

                activeTable = tableMap.getMap().get(newType);
                activeTable.setPrefWidth(tablePane.getWidth());
                activeTable.setPrefHeight(tablePane.getHeight());
                activeTable.setColumnResizePolicy(TableView
                        .CONSTRAINED_RESIZE_POLICY);


                newButton.setDisable(!((MicroController) activeTable).newMicrosAreAllowed());

                selectedSet = null;
                deleteButton.setDisable(true);
                duplicateButton.setDisable(true);

                activeTable.getSelectionModel().selectedItemProperty().
                        addListener(listener);
            });

    // Define an event filter for the ComboBox for Mouse_released events
    EventHandler validityFilter = new EventHandler<InputEvent>() {
        public void handle(InputEvent event) {
            try{
                ((MicroController)activeTable).checkValidity(activeTable.getItems());

            } catch (ValidationException ex){
                Dialogs.createErrorDialog(tablePane.getScene().getWindow(),
                        "Microinstruction Error", ex.getMessage()).showAndWait();

                event.consume();
            }
        }
    };
    microinstructionCombo.addEventFilter(MouseEvent.MOUSE_RELEASED, validityFilter);
}
 
源代码11 项目: CPUSim   文件: EditModulesController.java
/**
 * initializes the dialog window after its root element has been processed.
 * contains a listener to the combo box, so that the content of the table will
 * change according to the selected type of microinstruction.
 *
 * @param url the location used to resolve relative paths for the root
 *            object, or null if the location is not known.
 * @param rb  the resources used to localize the root object, or null if the root
 *            object was not localized.
 */
@Override
public void initialize(URL url, ResourceBundle rb) {

    moduleCombo.setVisibleRowCount(4); // show all modules at once

    tableMap.setParents(tablePane);
    tablePane.getChildren().clear();
    activeTable = tableMap.getMap().get("Register");
    tablePane.getChildren().add(activeTable);

    activeTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    activeTable.getSelectionModel().selectedItemProperty().addListener
            (contentChangeListener);

    // resizes the width and height of the content panes
    tablePane.widthProperty().addListener((observableValue, oldValue, newValue) ->
                    activeTable.setPrefWidth((Double) newValue)
    );
    tablePane.heightProperty().addListener((observableValue, oldValue, newValue) ->
                    activeTable.setPrefHeight((Double) newValue)
    );

    // listen for changes to the instruction combo box selection and update
    // the displayed micro instruction table accordingly.
    moduleCombo.getSelectionModel().selectedItemProperty().addListener(
            (selected, oldType, newType) -> {
                ((ModuleController) activeTable).setClones(activeTable.getItems());

                activeTable.getSelectionModel().selectedItemProperty().
                        removeListener(contentChangeListener);
                tableMap.getMap().get(oldType).getSelectionModel().clearSelection();
                tablePane.getChildren().clear();
                tablePane.getChildren().add(
                        tableMap.getMap().get(newType));

                activeTable = tableMap.getMap().get(newType);
                activeTable.setPrefWidth(tablePane.getWidth());
                activeTable.setPrefHeight(tablePane.getHeight());
                activeTable.setColumnResizePolicy(TableView
                        .CONSTRAINED_RESIZE_POLICY);

                newButton.setDisable(!((ModuleController) activeTable)
                        .newModulesAreAllowed());

                if (oldType.equals("Register") || oldType.equals("RegisterArray")) {
                    ((ConditionBitTableController) tableMap.getMap().get
                            ("ConditionBit")).updateRegisters();
                }

                propertiesButton.setDisable(!newType.equals("RegisterArray") ||
                                            activeTable.getItems().size() == 0);

                selectedSet = null;
                deleteButton.setDisable(true);
                duplicateButton.setDisable(true);

                //listen for changes to the table selection and update the
                // status of buttons.
                activeTable.getSelectionModel().selectedItemProperty().
                        addListener(contentChangeListener);
            });

    // Define an event filter for the ComboBox for Mouse_released events
    EventHandler validityFilter = new EventHandler<InputEvent>() {
        public void handle(InputEvent event) {
            try {
                ((ModuleController) activeTable).checkValidity();

            } catch (ValidationException ex) {
                Dialogs.createErrorDialog(tablePane.getScene().getWindow(),
                        "Modules Error", ex.getMessage()).showAndWait();
                event.consume();
            }
        }
    };
    moduleCombo.addEventFilter(MouseEvent.MOUSE_RELEASED, validityFilter);
}
 
源代码12 项目: CPUSim   文件: EditArrayRegistersController.java
/**
 * initializes the dialog window after its root element has been processed.
 * contains a listener to the combo box, so that the content of the table will
 * change according to the selected type of microinstruction.
 *
 * @param url the location used to resolve relative paths for the root
 *            object, or null if the location is not known.
 * @param rb  the resources used to localize the root object, or null if the root
 *            object was not localized.
 */
@Override
public void initialize(URL url, ResourceBundle rb) {

    arrayCombo.getItems().addAll(registerArrays.stream().map(
            RegisterArray::getName).collect(Collectors.toList()));
    arrayCombo.getSelectionModel().select(selection);

    tableMap = new ChangeTable(registerArrays);
    tableMap.setParents(tablePane);
    tablePane.getChildren().clear();
    tablePane.getChildren().add(tableMap.getMap().get(selection));

    activeTable = tableMap.getMap().get(selection);
    activeTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    // resizes the width and height of the content panes
    tablePane.widthProperty().addListener((observableValue, oldValue, newValue) ->
                    activeTable.setPrefWidth((Double) newValue)
    );
    tablePane.heightProperty().addListener((observableValue, oldValue, newValue) ->
                    activeTable.setPrefHeight((Double) newValue)
    );

    // listen for changes to the instruction combo box selection and update
    // the displayed micro instruction table accordingly.
    arrayCombo.getSelectionModel().selectedItemProperty().addListener(
            new ChangeListener<String>() {
                @Override
                public void changed(ObservableValue<? extends String> selected,
                                    String oldType, String newType) {
                    ((RegisterArrayTableView) activeTable).setClones(activeTable
                            .getItems());
                    activeTable = tableMap.getMap().get(newType);
                    tableMap.getMap().get(oldType).getSelectionModel()
                            .clearSelection();
                    tablePane.getChildren().clear();
                    tablePane.getChildren().add(
                            tableMap.getMap().get(newType));
                    activeTable.setPrefWidth(tablePane.getWidth());
                    activeTable.setPrefHeight(tablePane.getHeight());
                    activeTable.setColumnResizePolicy(TableView
                            .CONSTRAINED_RESIZE_POLICY);

                }
            });

    // Define an event filter for the ComboBox for Mouse_released events
    EventHandler validityFilter = new EventHandler<InputEvent>() {
        public void handle(InputEvent event) {
            try {
                ObservableList<Register> list = FXCollections.observableArrayList();
                list.addAll(registerController.getItems());
                for (RegisterArrayTableView r : tableMap.getMap().values()) {
                    list.addAll(r.getItems());
                }

                Validate.allNamesAreUnique(list.toArray());
                ((RegisterArrayTableView) activeTable).checkValidity(list);
            } catch (ValidationException ex) {
                Dialogs.createErrorDialog(tablePane.getScene().getWindow(),
                        "Registers Error", ex.getMessage()).showAndWait();
                event.consume();
            }
        }
    };
    arrayCombo.addEventFilter(MouseEvent.MOUSE_RELEASED, validityFilter);
}
 
源代码13 项目: chart-fx   文件: ChartPlugin.java
/**
 * Registers event handlers that should be added to the {@code XYChartPane} node when the plugin is added to the
 * pane and are removed once the plugin is removed from the pane.
 *
 * @param eventType the event type on which the handler should be called
 * @param handler the event handler to be added to the chart
 */
protected final void registerInputEventHandler(final EventType<? extends InputEvent> eventType,
        final EventHandler<? extends InputEvent> handler) {
    mouseEventHandlers.add(new Pair<>(eventType, handler));
}
 
 类所在包
 类方法
 同包方法