Skip to content
Advertisement

Why are my JavaFX buttons unevenly spaced?

I’m new to JavaFX, trying to build a GUI program that displays a bill for a table at a restaurant when you click on that table. The spacing is off between the table buttons and I’m not sure why.

enter image description here

The GUI class for my program:

JavaScript

Advertisement

Answer

From the Javadoc:

  • Row/Column Sizing

    By default, rows and columns will be sized to fit their content; a column will be wide enough to accommodate the widest child, …

The label in row 0 column 1 forces that column to be wider.

You probably want the label to be centered and span all 3 columns.

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