IRGeekSauce IRGeekSauce - 2 years ago 122
Java Question

How to set size and various attributes for all grids in GridPane in Scenebuilder/JavaFX

NOTE: This is not homework. My Swing application was homework, but it's already completed. I'm doing this for my own knowledge to get a better understanding of JavaFX and Scenebuilder.

I created a Swing application that contained a 27x27 grid. Upon clicking "Normal Setup", only the center square is visible.

Swing GUI Initialization

I am attemtping to translate everything into JavaFx, and I am using Scenebuilder. I'm still learning how to use this, and I'm unsure if I have my GridPane placed correctly (Notice how creating a 27 x 27 grid makes it go beyond the bounds of the parent). I can work on that later.

JavaFX GridNode with Scenebuilder

What I would like to know is if you can set all of the attributes for each node across the board. I had to go into my FXML file and manually change each node size in the 27x27 grid. This will get exhausting eventually. Surely there is a way to do this?
As you can see each node will have a Label template, and it will only be visible when a certain ant accesses it.

In my Swing version, an example of setting everything for all nodes looks like so:

setPreferredSize(new Dimension(ColonyView.NODE_SIZE, ColonyView.NODE_SIZE));

where the "NODE_SIZE" is:

public final static int NODE_SIZE = 96

Any help would be appreciated.

jns jns
Answer Source

Select a node in your GridPane and press STRG + A

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download