What contributes to a labels width?

Randahl Fink Isaksen randahl at rockit.dk
Tue Dec 4 12:06:27 PST 2012


I am trying to calculate the width of a label before it has been laid out by simulating its width as follows:

			Text text = new Text();
			text.setFont(label.getFont());
			text.setText(label.getText());
			Bounds bounds = text.getLayoutBounds();
			double labelWidth = Math.ceil(bounds.getWidth());

Unfortunately, it seems the label width I am predicting is a little less than the actual width of the label after layout (69 vs. 71). Could anyone enlighten me here – what else contributes to the width of the label than the font and the text?

(or could this be attributed to rounding differences inside label and text?)

Thanks

Randahl


More information about the openjfx-dev mailing list