How do I get all nodes in a parent in JavaFX?

后端 未结 6 1563
耶瑟儿~
耶瑟儿~ 2020-12-29 09:58

In C# I found a method that was pretty sweet that allowed you to get all the descendants and all of THEIR descendants from a specified control.

I\'m looking for a si

6条回答
  •  Happy的楠姐
    2020-12-29 10:07

    This seems to get ALL nodes. (In Kotlin)

    fun getAllNodes(root: Parent): ArrayList {
        var nodes = ArrayList()
        fun recurseNodes(node: Node) {
            nodes.add(node)
            if(node is Parent)
                for(child in node.childrenUnmodifiable) {
                    recurseNodes(child)
                }
        }
        recurseNodes(root)
        return nodes
    }
    

提交回复
热议问题