0

So this is what I am trying to do:

I want a scene showing 31 Panes, which then will be filled with either red or green color. (Clicking them should change the color)

I am wondering right now what is the best way to implement that. I first thought about a table View, but didnt really find a way to do this. The only option I can think of now is building it manually with 31 Anchor Panes.

Has anyone maybe a better idea?

Jakob Abfalter
  • 4,980
  • 17
  • 54
  • 94

1 Answers1

1

Use a TilePane, see the Catwhack program.

TilePane tiles = new TilePane();
tiles.setMinSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
tiles.setPrefColumns(4);
for (int i = 0; i <16; i++) {
    tiles.getChildren().add(
        new ExplodableItem(
           objectImage, 
           explosionImage, 
           NUM_CELLS_PER_EXPLOSION
        )
    );
}
Community
  • 1
  • 1
jewelsea
  • 150,031
  • 14
  • 366
  • 406