Reputation: 21
I was wondering if it is possible to add Button
s to a Canvas
. I am using a StackPane
as the parent and I put the Canvas
inside of it.
Upvotes: 0
Views: 845
Reputation: 5833
No.
The method protected ObservableList<Node> getChildren()
is part of the class Parent
. Pane
for example extends Region
which extends Parent
(which then extends Node
(which can be added to the ObservableList
returned by getChildren(...)
)). So only sub classes of Parent
can have children (if the implementing class makes getChildren(...)
public).
A Canvas
on the other hand extends Node
directly and therefore has no getChildren(...)
method.
Disclaimer: Please also note that you can't generally assume that a class can't do X because it doesn't extend Y. The reasoning above relies on the assumption that you are working with a well designed library.
Upvotes: 2