How to instantiate FXML Objects?
posted 1 year ago
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.