This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of TensorFlow 2.0 in Action and have Thushan Ganegedara on-line!
See this thread for details.
Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

The getChildren( ) method gets me confused

 
Ranch Hand
Posts: 330
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose that I have the following codes:


So, the getChildren() method of the VBox class returns an object of ObservableList<Node>. Therefore, I could do the following:

Now, in the case of root.getChildren().addAll(child1, child2, child3); is there a list inside root, that receives the outcome of
invoking the getChildren() method?  Please clarify this for me.
 
Marshal
Posts: 70711
288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know, but please start by posting a link to the method's documentation.
 
Sheriff
Posts: 15953
265
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Biniman Idugboe wrote:So, the getChildren() method of the VBox class returns an object of ObservableList<Node>. Therefore, I could do the following:

Now, in the case of root.getChildren().addAll(child1, child2, child3); is there a list inside root, that receives the outcome of
invoking the getChildren() method?  Please clarify this for me.


The expression root.getChildren() is the list, as you showed in the two lines of code.

root.getChildren() is equivalent to line 1, except you're using the reference to the list directly instead of assigning it to a variable.
 
Biniman Idugboe
Ranch Hand
Posts: 330
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The getChildren( ) definition at /javafx.graphics/javafx/scene/layout/Pane.html

i.  root.getChildren() creates an empty list in memory
ii.  The list is not assigned to a variable. Fair to say the list is anonymous
iii.  Three Button objects are added to the list.
iv.  So far, in my opinion, VBox object is not the same thing as the anonymous list.  Three items have been added to the list, not to VBox object.
v.  The VBox object, carrying the anonymous list with it, is then used to construct a scene. My question is, at what point did the
anonymous list get inserted into the VBox object?  No offense intended. I am only seeking to understand what is happening.

 
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Biniman Idugboe wrote:
So, the getChildren() method of the VBox class returns an object of ObservableList<Node>. Therefore, I could do the following:


No, that jump is not logical. root.getChildren() returns the root's internal List, while ObservableList<Node> list = root.getChildren() is a new List, completely disconnected from root.
[Edit: sorry, this is wrong.]
 
Biniman Idugboe
Ranch Hand
Posts: 330
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see.  Thanks for the clarification.
 
Junilu Lacar
Sheriff
Posts: 15953
265
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:

Biniman Idugboe wrote:
So, the getChildren() method of the VBox class returns an object of ObservableList<Node>. Therefore, I could do the following:


No, that jump is not logical. root.getChildren() returns the root's internal List, while ObservableList<Node> list = root.getChildren() is a new List, completely disconnected from root.



How is it not logical and how is it a new list? The list variable is a reference variable that is assigned the value returned by root.getChildren(). It's not a new list and it's the same exact list that would be operated on by root.getChildren().addAll().
 
Knute Snortum
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right.  Sorry.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic