java - Add a Node to a class that extends Scene -
how can add custom pane custom scene in code?
public class mainscene extends scene {   public mainscene() {     super(new flowpane(), 800, 600);   }    public void additem(string name) {     item item = new item(name); // item extends pane.     getroot().getchildren().add(item); // doesn't work.   } } 
in example, not have reference root element.
without asking user, cannot pass reference of root element because of use of super().
since getroot() returns parent, cannot use getchildren() on obvious reasons.
what can type-cast getroot() flowpane.
public void additem(string name) {     pane item = new pane(); // item extends pane.     ((flowpane)getroot()).getchildren().add(item); } 
Comments
Post a Comment