问题
In one of our rcp application's window, I need to set label text dynamically after the creation of the window.
When the window is created I would have created the label control but I would not set the text by then. After user selects a button on the window, I want to set the text of the label inside the button's selection listener method. After setting text to label inside button's selection listener method I am not able to see the text on the window.
Why is that I am not able to see the label text on the window when I set it inside the listener method? Is it because the window is already created?
how do I solve this?
回答1:
The Size of the Label is not getting updated after the call to setText()
. Try calling parent.layout()
after setText()
where the parent
is the Composite
containing your label control.
回答2:
I guess it is something to do with how you layout the label. after setting text on Label
, do re-layout or adjust its bounds.
来源:https://stackoverflow.com/questions/12862429/java-rcp-not-able-to-dynamically-set-text-to-swt-label-control