简体   繁体   English

JavaFX:如何在第一次显示ListView之前计算ListCell的坐标

[英]JavaFX: How to calculate coordinates of ListCell before the ListView is shown the first time

I need a solution to get the coordinates from a ListCell of a ListView before the listView is displayed the first time. 我需要一个解决方案来在第一次显示listView之前从ListViewListCell获取坐标。 Because, I have to move a Stage (contains the ListView ) which depends on these coordinates. 因为,我必须移动一个依赖于这些坐标的Stage (包含ListView )。

Before stage is shown, no one node is allocated (as far as I remember, mostly - performance concern). 在显示阶段之前,没有分配任何节点(据我所知,主要是性能方面的问题)。

So, actual sizes and positions don't exist until content is rendered at the first time. 因此,直到第一次渲染内容时,实际大小和位置才存在。 So, to move the stage properly, you should add listeners on properties, describing position, and move stage on position changes. 因此,要正确移动舞台,应在属性上添加侦听器,以描述位置,并在位置变化时移动舞台。

Or move stage later, on some other event (mouse click, or smth else), when you can be sure, that coordinates exist and determined correctly. 或稍后再移动舞台,如果可以确定其他坐标(鼠标单击或其他),坐标将正确存在并确定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM