Issue
Sample code:
HBox pane = new HBox(10); //new HBox pane pane.getChildren().addAll(lbl, btnAdd, btnSubtract);
I know how to implement and get this code to do what I want, but I'm not sure what each piece does. It would make more sense if I did not have to specify the lbl,btnadd,btnsubtract objects. If it executes addAll why do I have to specify all the buttons I already have?
Solution
If your button is already in the list of children that the HBox
has, then you should not add it in. On the other hand, if your HBox
does not have that child (e.g. Button btnAdd
), then it wouldn't appear at all if you don't add it in.
If you are imagining that the HBox
would magically make lbl
, btnAdd
and btnSubtract
into its children because you have simply created those objects with codes, then you are wrong.
Answered By - Jai
Answer Checked By - Clifford M. (JavaFixing Volunteer)