Reputation: 306
I have a JavaFX application where I am updating 10 labels in a vbox. Below is the code that updates the labels:
String output = String.format("%-30s: %d", name, score);
labelArr[i].setText(output);
I would like the names to be aligned and the scores to be aligned, but here is what I am getting
*Excuse the dummy values
Upvotes: 0
Views: 236
Reputation: 173
You could put the labels inside of a GridPane
with two colums.
GridPane gp = new GridPane();
Upvotes: 2
Reputation: 5926
The simplest solution is using Monospace font:
label.setFont(new Font("Monospace", 12));
Upvotes: -1