roc08 2010-05-10 20:22
浏览 227
已采纳

GXT 显示问题

大家好 小弟初学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);
        
        
    }
    
}
  • 写回答

2条回答 默认 最新

  • iteye_20028 2010-05-14 10:19
    关注

    那你试试cpQuery.setLayoutOnChange(true);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码