Search code examples
javamultidimensional-arrayjavafxgridpaneborderpane

How to display elements of a 2-d array in a JavaFX GUI


I'm extremely new JavaFX (and any GUI for that matter), and I'm having troubles with understanding some concepts. That said, I have 10x10 multi-dimensional array that stores random int's within a class that extends GridPane, and I'm having troubles understanding how I would display each random int value graphically in the center of a BorderPane of another class. I would like each int of every element to be shown in a shape of sorts uniformly. I don't want to know an exact solution. I just want to be aware of what options and steps I should take e.g. imports I should be aware of etc. Found this image from a different post, but this the kind of layout I imagine, except I don't need them to be buttons

enter image description here


Solution

  • Build a (probably nested) loop and traverse the 2d-array. On each cycle get the int value from the class and put into one of appropriate built-in layout panes of JavaFX. I suggest to use another general/master GridPane or TilePane. Then put this master pane to center of BorderPane.