0
我第一次尝试是:创建复合材料,其适应我的数据在Eclipse SWT
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任何东西。至少当我尝试在Deisigner和Preview中呈现它时。当我在应用程序中使用它时,我必须测试它是否有效。但我不知道错误在哪里。
另一个不使用这些设计师的原因;) – Baz 2013-03-01 13:48:55
也许,但Disgner也给了我很多代码示例。很难找到设计师自己教给我的所有东西。所以最后:代码和Deigner的组合是最好的。人们必须了解设计师所做的和打破的;) – Tarion 2013-03-04 13:48:06