Changing the preferred size of an object does not change its size,
or trigger any geometry negotiation e.g. resetting the label of a Button
does not change the size
Changing the preferred size of an object automatically invalidates it.
To force a size recalculation for invalid children of
a Container call layout() on the Container.
This will force a resize each time the label is reset:
class AutoResizeButton extends Button {
public void setLabel(String name) {
super.setLabel(name);
getParent().layout();
}
}