Skip to content
Advertisement

Square GridPane of square cells

My goal is to create a GridView that is resizable, always square and contains an equal number of rows and columns, making their cells also square, similar to a Reversi or Chess board.

Here’s a small illustration, the grid is centered horizontally on the content pane.

enter image description here

I’ve tried a multitude of different binding variants and layouts, but I can’t quite get it right. Here’s my controller (so far):

JavaScript

And the cells, which are supposed to contain Shapes lates, but I’ve but Circles for now just to test it:

JavaScript

This is how it looks currently:

enter image description here

Advertisement

Answer

Solved it with a lot of tinkering, here’s my solution for future reference:

GameCell:

JavaScript

GamePane:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement