Gridpane 上的 getChildren 是否已排序? (javafx)

is getChildren on Gridpane sorted? (javafx)

我想通过索引获取 GridPane 中的节点,我知道您可以通过遍历 getChildren 来做到这一点,但我想知道是否有更简单的方法来做到这一点。如果我知道 getChildren 已排序,则可以通过 getChildren.get( row*width + column) 完成,但在执行此操作之前我需要知道它是否以某种方式排序。

getChildren() 只是 returns 对 List. The order of the elements in that list is determined entirely by the methods you call on it and the order you call them. E.g. calling add(child) will add an element (a Node) to the end of the list, so if all you do is call add repeatedly, the nodes will be arranged in the list in the order you add them. If you call add(index, child) the child node will be added at the specified index (so if you repeatedly call add(0, child) the child nodes will be in the reverse of the order in which you add them. If you call addAll(nodes) 的引用,子节点将按照它们出现在列表末尾的顺序添加,等等

所以最重要的是你可以控制列表中子节点的顺序是你想要的任何顺序。