Учитывая следующую ситуацию:
// Initializing a new composite within a parent UI container
Composite composite = new Composite(parent, SWT.NONE);
Label label = new Label(composite, SWT.NONE);
label.setText("Hi. I am a label and I'm drawn correctly.");
Display.getDefault().syncExec(new Runnable() {
// Here I'm trying to draw a new label onto this composite
Label newLabel = new Label(composite, SWT.NONE);
Label.setText("I am a test label. You should see me now.");
// Change the text of 'label' here
label.setText("Uh-oh. My text has been altered.");
// Let's redraw the parent UI component to see the new label drawn
parent.redraw();
});
newLabel
никогда не рисуется, хотя текст label
был визуально изменен.Аналогично, размещение элемента пользовательского интерфейса в пределах syncExec()
приводит к его визуальному удалению.Почему это так?
Я не вижу веской причины, по которой это невозможно.