Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes 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: 299
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should add an mcve
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic