tags:

views:

241

answers:

1

If you are extending UIComponent and you add a Label component to your custom component it seems you have to use setActualSize() in order for your label to appear. The problem is I don't know what size the label is going to be as it depends on the length of the text and the font size. Sometimes this works:

label.setActualSize(label.getExplicitOrMeasuredWidth(),
    label.getExplicitOrMeasuredHeight())

but not always. I'm not sure of the reason for this.

What's the best way to set a label to its actual size?

thanks

A: 

Make sure you call setActualSize() on the Label in your UIComponent's updateDisplayList() function. That's where it's supposed to happen. If you call it anywhere else in the validation cycle, the child Label may not have finished measurement.

joshtynjala