简体   繁体   中英

Java RCP - Not able to dynamically set text to SWT label control

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM