0

我的第一次尝试是:

public MultiLangugeText(Composite parent, int style) {
    super(parent, style);
    setLayout(new RowLayout(SWT.HORIZONTAL));

    Map<Locale, String> texts = new HashMap<Locale, String>();
    texts.put(Locale.GERMAN, "Hey du");
    texts.put(Locale.ENGLISH, "Hey you");
    texts.put(Locale.FRENCH, "Bon Jour");
    setTexts(texts);

public void setTexts(Map<Locale, String> texts) {
    for (Locale locale : texts.keySet()) {
        createTextComposite(locale, texts.get(locale));
    }
}

private void createTextComposite(Locale locle, String localizedString) {
    Composite composite = formToolkit.createComposite(this, SWT.BORDER);
    formToolkit.paintBordersFor(composite);
    composite.setLayout(new RowLayout(SWT.HORIZONTAL));

    CLabel label = new CLabel(composite, SWT.NONE);
    label.setText(locle.toString());
    formToolkit.adapt(label);
    formToolkit.paintBordersFor(label);

    Text txtString = new Text(composite, SWT.BORDER);
    txtString.setText(localizedString);
    formToolkit.adapt(txtString, true, true);
}

但是这段代码不会在我的 UI 上绘制任何东西。至少当我尝试在设计器和预览中渲染它时。当我在我的应用程序中使用它时,我必须测试它是否有效。但我不明白错误在哪里。

4

1 回答 1

0

好的,它只会在设计器中失败,而不是在您实际使用复合材料 elsewehre 时。

于 2013-03-01T13:16:32.283 回答