Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在我的 javafx 应用程序中有一个带有 ImageViews 的HBox,现在我需要一些方法来遍历这个 HBox,但我找不到如何做到这一点的算法,我试图做这样的事情:
Object[] stack = stackWrapp.getChildren().toArray();
其中 stack 是我的HBox,但是以这种方式的 ImageViews 将被复制,这是我不想要的。我不知道为什么所以我该怎么做..
你可以这样做:
for (Node child : stackWrapp.getChildren()) { ImageView imgView = (ImageView) child; ... }
为了节省起见,您还可以在转换之前进行类型检查,以防万一Nodes您的HBoxnot only ImageView.
Nodes
HBox
ImageView