What contributes to a labels width?

Mark Fortner phidias51 at gmail.com
Tue Dec 4 12:33:04 PST 2012

I think the Label has an inset which may account for the difference between
the Text width and the Label width.




On Tue, Dec 4, 2012 at 12:06 PM, Randahl Fink Isaksen <randahl at rockit.dk>wrote:

> 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