• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

JavaFx question

 
Ranch Hand
Posts: 545
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys there doesn't seem to be very many tutorials on layouts without using fxml online anyway if anybody knows the answer to this question that would be great,

my question is so in this code I created a new GridPane called root and added components a button and also a label

but then to change the positions I called GridPane.setConstraints() the thing is how is this possible? how does our GridPane root know where the items are positioned since we are using a static method of the GridPane class and not an our instance root,I thought it would make more sense to say root.setConstraints since that is the actual isntance and the actual object that contains label and button

thanks

 
Marshal
Posts: 82459
594
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you read the specification for that method and what ti does? I think that might explain things. Meanwhile I shall move you to our FX forum.
 
Adam Chalkley
Ranch Hand
Posts: 545
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Campbell thanks for the reply,I read the documentation before I posted and still couldn't figure out why it is static instead of non static

any ideas?

thanks
 
Campbell Ritchie
Marshal
Posts: 82459
594
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look what the constraints are applied to.
 
Adam Chalkley
Ranch Hand
Posts: 545
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
they are applied to nodes,so basically it just changes the properties of the individual nodes rather than the instance of the gridpane itself?

thanks
 
Campbell Ritchie
Marshal
Posts: 82459
594
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well done
You have twigged how to interpret the documentation. Yes, applying the constraints to the node rather than the pane means the method can be static in the pane class. Remember that a grid pane might use different constraints for each node because you would want different sizes for all nodes, so you don't want to apply the constraints to the pane.

And yes, the method being static does look strange until you get used to it.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic