当前位置: 首页>>代码示例>>Java>>正文


Java Node.addEventFilter方法代码示例

本文整理汇总了Java中javafx.scene.Node.addEventFilter方法的典型用法代码示例。如果您正苦于以下问题:Java Node.addEventFilter方法的具体用法?Java Node.addEventFilter怎么用?Java Node.addEventFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.Node的用法示例。


在下文中一共展示了Node.addEventFilter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MouseTracker

import javafx.scene.Node; //导入方法依赖的package包/类
public MouseTracker(final Node owner) {
    owner.setOnMouseMoved(this.onMouseMovedEventHandler);
    owner.setOnMouseClicked(this.onMouseClickedEventHandler);
    owner.setOnMouseEntered(this.onMouseEnteredEventHandler);
    owner.setOnMouseExited(this.onMouseExitedEventHandler);
    owner.setOnMouseDragged(this.onMouseDraggedEventHandler);
    owner.setOnMousePressed(this.onMousePressedEventHandler);
    owner.setOnMouseReleased(this.onMouseReleasedEventHandler);

    // Register our own event handler to register mouse placement at all times
    owner.addEventFilter(MouseEvent.ANY, event -> {
        if(!Double.isNaN(event.getX())) {
            xProperty.set(event.getX());
        }
        if(!Double.isNaN(event.getY())) {
            yProperty.set(event.getY());
        }
    });
}
 
开发者ID:ulriknyman,项目名称:H-Uppaal,代码行数:20,代码来源:MouseTracker.java

示例2: setMouseListener

import javafx.scene.Node; //导入方法依赖的package包/类
protected void setMouseListener(Node node) {
    node.addEventFilter(MouseEvent.MOUSE_CLICKED, (e) -> {
        e.consume();
        if (selectedItem != null) {
            selectedItem.deselect();
        }
        selectedItem = CheckListItem.this;
        CheckListItem.this.select();
    });
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:11,代码来源:CheckList.java

示例3: start

import javafx.scene.Node; //导入方法依赖的package包/类
@Override public void start(Stage primaryStage) throws Exception {
    TreeViewSample root = new TreeViewSample();
    primaryStage.setScene(new Scene(root));
    // primaryStage.getScene().getRoot().addEventFilter(MouseEvent.MOUSE_CLICKED,
    // new EventHandler<Event>() {
    // @Override
    // public void handle(Event event) {
    // Node source = (Node) event.getSource();
    // MouseEvent me = (MouseEvent) event ;
    // EventTarget target = event.getTarget();
    // Node hit = getTarget((Node) event.getSource(), me.getX(), me.getY());
    // if(hit != target) {
    // System.err.println("Did not match");
    // System.err.println("event-target = " + target);
    // System.err.println("hit-target = " + hit);
    // }
    // }
    //
    // private Node getTarget(Node source, double x, double y) {
    // List<Node> hits = new ArrayList();
    // if(!(source instanceof Parent))
    // return source;
    // ObservableList<Node> children = ((Parent)
    // source).getChildrenUnmodifiable();
    // for (Node child : children) {
    // Bounds boundsInParent = child.getBoundsInParent();
    // x -= boundsInParent.getMinX();
    // y -= boundsInParent.getMinY();
    // if (x < 0.0 || y < 0.0)
    // continue;
    // checkHit(child, x, y, hits);
    // }
    // return hits.size() > 0 ? hits.get(hits.size() - 1) : source;
    // }
    //
    // private void checkHit(Node child, double x, double y, List<Node>
    // hits) {
    // Bounds boundsInParent = child.getBoundsInParent();
    // if(boundsInParent.contains(x, y)) {
    // hits.add(child);
    // if(!(child instanceof Parent))
    // return ;
    // x -= boundsInParent.getMinX();
    // y -= boundsInParent.getMinY();
    // ObservableList<Node> childrenUnmodifiable =
    // ((Parent)child).getChildrenUnmodifiable();
    // for (Node node : childrenUnmodifiable) {
    // checkHit(node, x, y, hits);
    // }
    // }
    // }
    // });
    primaryStage.show();
    Set<Node> lookupAll = root.lookupAll(".text");
    System.out.println("MyApp.start(): " + lookupAll.size());
    for (Node node : lookupAll) {
        node.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler<Event>() {
            @Override public void handle(Event event) {
                MouseEvent me = (MouseEvent) event;
                System.out.println("Bounds: " + ((Node) me.getSource()).getBoundsInParent());
                System.out.println("Source Coords: " + me.getX() + ", " + me.getY());
                System.out.println("Scene Coords: " + me.getSceneX() + ", " + me.getSceneY());
                System.out.println("Screen Coords: " + me.getScreenX() + ", " + me.getScreenY());
            }

        });
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:69,代码来源:MyApp.java

示例4: suppressFocusStyleOnPress

import javafx.scene.Node; //导入方法依赖的package包/类
public static void suppressFocusStyleOnPress(Node node) {
    node.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> suppressFocusStyle(node));
    node.focusedProperty().addListener((v, o, n) -> endSuppressionIfFocusLost(node));
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:5,代码来源:FocusHelper.java

示例5: suppressFocusStyleOnRelease

import javafx.scene.Node; //导入方法依赖的package包/类
public static void suppressFocusStyleOnRelease(Node node) {
    node.addEventFilter(MouseEvent.MOUSE_RELEASED, event -> suppressFocusStyle(node));
    node.focusedProperty().addListener((v, o, n) -> endSuppressionIfFocusLost(node));
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:5,代码来源:FocusHelper.java


注:本文中的javafx.scene.Node.addEventFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。