當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。