Java RCP-无法将文本动态设置为SWT标签控件 [英] Java RCP - Not able to dynamically set text to SWT label control
问题描述
在我们的rcp应用程序窗口之一中,我需要在创建窗口后动态设置标签文本.
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?
我该如何解决?
推荐答案
调用 setText()
后,标签的大小未得到更新.尝试在 setText()
之后调用 parent.layout()
,其中 parent
是包含标签控件的 Composite
.
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.
这篇关于Java RCP-无法将文本动态设置为SWT标签控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!