Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/328.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 我可以在GXT中的鼠标单击事件中将ContentPanel添加到ContentPanel中吗_Java_Gwt_Gxt - Fatal编程技术网

Java 我可以在GXT中的鼠标单击事件中将ContentPanel添加到ContentPanel中吗

Java 我可以在GXT中的鼠标单击事件中将ContentPanel添加到ContentPanel中吗,java,gwt,gxt,Java,Gwt,Gxt,我想在鼠标单击事件中删除ContentPanel中的所有元素并添加新元素。使用removeAll()方法可以很好地工作,这将删除所有现有组件。但当我想添加一个新组件时,它不会被添加 可能是这样的,我省略了click处理程序,但您应该从中了解到这一点 private ContentPanel contentPanel; public SwapScreen() { contentPanel = new ContentPanel(); add(contentPanel); } public v

我想在鼠标单击事件中删除ContentPanel中的所有元素并添加新元素。使用removeAll()方法可以很好地工作,这将删除所有现有组件。但当我想添加一个新组件时,它不会被添加

可能是这样的,我省略了click处理程序,但您应该从中了解到这一点

private ContentPanel contentPanel;

public SwapScreen() {
 contentPanel = new ContentPanel();
 add(contentPanel);
}

public void swap1() {

   /*This should be split into a separate
    method and called only once to avoid recreating them.*/
   field1 = new TextField<String>();
   contentPanel.add(field1);

   field2 = new TextField<String>();
   contentPanel.add(field2);

  this.layout(true);
}

public void swap2() {

   /*This should be split into a separate
    method and called only once to avoid recreating them.*/
   anotherField1 = new TextField<String>();
   contentPanel.add(anotherField1);

   anotherField2 = new TextField<String>();
   contentPanel.add(anotherField2);

   this.layout(true);
}
private ContentPanel ContentPanel;
公共交换屏幕(){
contentPanel=新的contentPanel();
添加(contentPanel);
}
公共空间1(){
/*这应该分成一个单独的部分
方法并仅调用一次以避免重新创建它们*/
field1=新文本字段();
contentPanel.add(字段1);
field2=新文本字段();
contentPanel.add(字段2);
这个布局(正确);
}
公共空间交换2(){
/*这应该分成一个单独的部分
方法并仅调用一次以避免重新创建它们*/
另一个字段1=新文本字段();
contentPanel.add(另一个字段1);
另一个字段2=新文本字段();
contentPanel.add(另一个字段2);
这个布局(正确);
}

最重要的部分是
这个布局(true)
要强制它刷新你的布局,

你能发布你的代码吗?您可能没有正确使用引用。。。