Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to instantiate FXML Objects?

 
Cameron Cunning
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings. I'm currently trying to make a battleship game, and I've drawn the board up in SceneBuilder. Basically I've created a 10x10 GridPane and in each cell I have placed an BoardTile object which extends javafx rectangle. During the set up ships portion of the game, the user will choose where to place their ships. I'd like to have each BoardTile object in a two dimensional array for easy access/calculations, but I'm getting null pointer exceptions. Experimentation has shown that at times a certain number of the BoardTile objects are instantiated, and a certain number remain null. How can I force the FXML file to instantiate all the BoardTile objects upon loading? Thanks for any help.
 
John Damien Smith
Ranch Hand
Posts: 320
19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should add an mcve
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!