Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在EclipseSWT中创建一个适合我的数据的组合_Java_Eclipse_User Interface_Swt_Composite - Fatal编程技术网

Java 在EclipseSWT中创建一个适合我的数据的组合

Java 在EclipseSWT中创建一个适合我的数据的组合,java,eclipse,user-interface,swt,composite,Java,Eclipse,User Interface,Swt,Composite,我的第一次尝试是: 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"

我的第一次尝试是:

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);
}
公共多语言文本(复合父级,int样式){ 超级(父母,风格); setLayout(新行布局(SWT.水平)); 映射文本=新的HashMap(); text.put(Locale.derman,“Hey du”); text.put(Locale.ENGLISH,“Hey you”); text.put(Locale.FRENCH,“Bon Jour”); setTexts(文本); 公共void setTexts(地图文本){ for(区域设置:text.keySet()){ createTextComposite(locale,text.get(locale)); } } 私有void createTextComposite(区域设置locle、字符串localizedString){ Composite Composite=formToolkit.createComposite(这是SWT.BORDER); formToolkit.paintBordersFor(复合); 复合.setLayout(新的行布局(SWT.HORIZONTAL)); CLabel label=新CLabel(复合,SWT.NONE); label.setText(locle.toString()); formToolkit.adapt(标签); formToolkit.油漆边框(标签); Text txtString=新文本(复合,SWT.BORDER); setText(本地化字符串); adapt(txtString,true,true); }
但这段代码不会在我的UI上绘制任何东西。至少当我尝试在designer和预览中呈现它时是这样。我必须测试这是否有效,当我在应用程序中使用它时。但我不知道错误在哪里。

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

不使用它的另一个原因e设计师;)也许吧,但设计师也给了我很多代码示例。很难找到设计师自己教给我的所有东西。所以最后:代码和设计师的结合是最好的。我们必须了解设计师做了什么和打破了什么;)