How to get Label Size with Text

I try to center a Lemur Label with a multi-line text over my character. My guess was to get the size of the label which is spawned for the given text with label.getSize() which would return a Vector3f. But that is always 0, 0, 0.
Any ideas? Or is there another way to center a Label with multi-line over a given position (in my case the camera.getScreenCoordinates(playerpos))?


getSize() will only tell you the real size after the GUI element is “real”, ie: on the screen, sized in a layout, etc…

getPreferredSize() is what you want for a Label that has its text but hasn’t been added anywhere yet.


thanks for the quick answer :smile: