Daniel Peñalba Daniel Peñalba - 17 days ago 6
Java Question

SWT label size is not correctly updated

I'm new in Java/SWT. I'm experiencing some troubles using a SWT label.

When I update the text on the label, its size is not correctly updated (the label is cut, respecting the original size). However, if I perform a very small resize in my dialog, the size is updated correctly.

Basically, I create the label with a default text and then, when I load data I update the label with the real text, that is bigger than the original one.

I tried calling

label.update()
and
label.redraw()
without luck.

Please, someone could help me with this issue?

Thanks in advance.

Answer

Try to call parent.layout(), where parent is the Composite which contains your label. Also see Understanding Layouts in SWT.