文档 – 在JavaFX中获取节点的全局坐标
| 如何获取场景中节点的实际位置.绝对的位置,不管任何容器/转换. 
  
  例如,我想要翻译某个节点a,以便它暂时与另一个节点b重叠.所以我希望将其translateX属性设置为b.globalX-a.globalX. 文件说: 
 child.layoutX = finalX - child.layoutBounds.minX; 也就是说,任何节点的最终坐标应该是 finalX = node.layoutX + node.layoutBounds.minX 但是运行以下代码: var rect;
Stage {
    title: "Application title"
    width: 250
    height:250
    scene: Scene {
        content: [
            Stack{content:[rect = Rectangle { width:10 height:10}] layoutX:10}
        ]
    }
}
println("finalX = {rect.layoutX+rect.layoutBounds.minX}");给我finalX = 0.0,而不是finalX = 10.0,因为文档看起来状态. 有没有一个明确的方法来获得JavaFX中绝对最终的定位坐标? 解决方法
 对于边界: 
  
  
  bounds = rect.localToScene(rect.getBoundsInLocal()); 为JavaFx 1和2工作. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! | 
