Get real position of a node in JavaFX

后端 未结 3 1197
感情败类
感情败类 2020-12-06 17:06

What is the best way to get the absolute position of a node in JavaFX?

Imagine we have a node in a Pane (Hbox, Stackpane, or any other pane) and that may have a pare

3条回答
  •  半阙折子戏
    2020-12-06 17:57

    Assuming the name of the main Stage "window",and the name of the node "menu" you can do this :-)

    double X=Main.window.getX()+menu.getLayoutX();
    double Y=Main.window.getY()+menu.getLayoutY();
    

提交回复
热议问题