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

纵然是瞬间 提交于 2019-12-11 14:45:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!