大家好 小弟初学gxt 有此想法不知道能不能实现,
我想在window面板中加入一个下拉菜单和一个按钮,点击此按钮后 在window面板的下部分出现一个新的ContentPanel 里面的内容根据下拉菜单选择的条件的不同产生。
我在按钮的监听事件中新建一个新的ContentPanel,加入内容并加入window后,发现他根本不能在原来的window中显示 。代码如下,附图
public class ComplexQuery { final DataServiceAsync serviceProxy=GWT.create(DataService.class); final ListStore<Plant> store = new ListStore<Plant>(); final ListStore<HeadList> header = new ListStore<HeadList>(); final ContentPanel cpQuery = new ContentPanel(); public void onRender() { Window window=new Window(); window.setSize(600, 400); HorizontalPanel hhPanel=new HorizontalPanel(); Button sumbitButton=new Button("查询"); cpQuery.setHeaderVisible(false); getHeadList(); ComboBox<HeadList> comboQuery = new ComboBox<HeadList>(); comboQuery.setEmptyText("选择查询方案"); comboQuery.setDisplayField("name"); comboQuery.setWidth(200); comboQuery.setStore(header); comboQuery.setTypeAhead(true); comboQuery.setTriggerAction(TriggerAction.ALL); sumbitButton.addSelectionListener(new SelectionListener<ButtonEvent>() { public void componentSelected(ButtonEvent ce) { creatHorizontalPanel(); } } ); hhPanel.add(comboQuery); hhPanel.add(sumbitButton); cpQuery.add(hhPanel); window.add(cpQuery); window.show(); } public void getHeadList(){ serviceProxy.getHeadList(new AsyncCallback<List<HeadList>>(){ public void onSuccess(List<HeadList> result){ //MessageBox.alert("OM", "OK", null); header.add((List<HeadList>) result); } @Override public void onFailure(Throwable caught) { MessageBox.alert("OM", "ON", null); } }); } public void creatHorizontalPanel(){ HorizontalPanel h1=new HorizontalPanel(); Button button=new Button(); h1.add(button); cpQuery.add(h1); } }