GWT:浏览器滚动没有出现

时间:2014-05-27 01:54:53

标签: gwt

我在GWT中有一个小应用程序,主页面的initWidgetVerticalPanel,内部只有其他VerticalPanel和horizo​​ntalPanel。

但我无法看到浏览器滚动。 verticalpanels超出了浏览器高度,但出现了滚动条。

请知道原因可能是什么。

感谢

代码::

private Button btnLoad = new Button("load more results");
private CheckBox check_byPakag= new CheckBox("by package");
private CheckBox check_Inheritance= new CheckBox("by inheritance");
private CheckBox check_byComposition= new CheckBox("by composition");
private CheckBox check_byDependency= new CheckBox("by dependency");
private VerticalPanel vpnl_Main = new VerticalPanel();
private FlowPanel flowpanelImages = new FlowPanel();
private VerticalPanel scrollImages;
private IndexServiceAsync rpcService = GWT.create(IndexService.class);
private SuggestBox text_Wild_Card;
private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
private int start = 0;
private int finish = 10;  // Total number of results to display at first time 
private int totalNumberOfResultsToShow = 10; //Total number of results to display on every call(when load more results button is pressed)
private int scrollPosition = 0;
private VerticalPanel vpnlScroll = new VerticalPanel();


public MainPageView(){
    check_byPakag.setChecked(true);
    check_Inheritance.setChecked(true);
    check_byComposition.setChecked(true);
    check_byDependency.setChecked(true);
    initWidget(vpnl_Main);
    getSuggestions();
    scrollImages = new VerticalPanel();
    scrollImages.add(vpnlScroll);
    vpnlScroll.add(flowpanelImages);

    btnLoad.setEnabled(false);
    vpnl_Main.setSpacing(4);


    Window.addResizeHandler(new ResizeHandler(){

        @Override
        public void onResize(ResizeEvent event) {
        }});
}

public void getSuggestions(){
    rpcService.getAllSuggestions(new AsyncCallback<List<String>>(){

        @Override
        public void onFailure(Throwable caught) {
            System.out.println(caught.getMessage());
        }

        @Override
        public void onSuccess(List<String> result) {

            for(int i=0;i<result.size(); i++){
                oracle.add(result.get(i));
            }

            text_Wild_Card = new SuggestBox(createWildCardOracle());
            text_Wild_Card.setText("*");
            layout(vpnl_Main);
            getIndexData();
        }});
    }

@SuppressWarnings("deprecation")
public void getIndexData(){
    final DecoratedPopupPanel popup = new DecoratedPopupPanel();
    popup.setWidget(new Label("Loading.."));
    popup.center();

    rpcService.getIndexData(text_Wild_Card.getText(), check_byPakag.isChecked(), check_Inheritance.isChecked(), check_byComposition.isChecked(), check_byDependency.isChecked(), start, finish, new AsyncCallback<IndexDataSet>(){

        @Override
        public void onFailure(Throwable caught) {
            Window.alert("getIndexData failed"+ caught.getMessage());
        }

        @Override
        public void onSuccess(IndexDataSet result) {
            flowpanelImages.clear();

            if(result.hasMore()){
                btnLoad.setEnabled(true);
            }else{
                btnLoad.setEnabled(false);
            }
            for(int i=0; i< result.getResults().size(); i++){
                final Image image = new Image(result.getResults().get(i).stampImageURL);
                //////////////
                final Label lbl = new Label("dummy");
                lbl.setStyleName("invisibleImageLabel");
                VerticalPanel vpnlImage = new VerticalPanel();
                vpnlImage.add(image);
                vpnlImage.add(lbl);

                //////////


                final DataImage dataImage = new DataImage();
                dataImage.setUrl(result.getResults().get(i).stampImageURL);
                dataImage.setDescription(result.getResults().get(i).description);
                image.addMouseOverHandler(new MouseOverHandler(){

                    @Override
                    public void onMouseOver(MouseOverEvent event) {
                        lbl.setText(dataImage.getDescription());
                        lbl.setStyleName("imageLabel");
                    }});

                image.addMouseOutHandler(new MouseOutHandler(){

                    @Override
                    public void onMouseOut(MouseOutEvent event) {
                        lbl.setStyleName("invisibleImageLabel");
                    }});

                image.addClickHandler(new ClickHandler(){


                    @Override
                    public void onClick(ClickEvent event) {

                        RootPanel.get("bodyContainer").clear();
                        History.newItem("diagramView / "+dataImage.getUrl());
                    }});
                vpnlImage.addStyleName("imageStyle");
                vpnlImage.addStyleName("paddedFlowPanel");
                flowpanelImages.add(vpnlImage);

            }
            //
            HorizontalPanel hpnlBtn = new HorizontalPanel();
            hpnlBtn.setWidth("100%");
            hpnlBtn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
            hpnlBtn.add(btnLoad);
            btnLoad.setStyleName("nextLine");
            flowpanelImages.add(hpnlBtn);

        popup.removeFromParent();
        }});
}


private SuggestOracle createWildCardOracle() {
    return oracle;

}

private void layout(VerticalPanel vpnl_Main) {
    FlexTable flexWildCard = new FlexTable();
    VerticalPanel vpnlCheckBoxes = new VerticalPanel();
    HorizontalPanel hpnlWildCard = new HorizontalPanel();
    flexWildCard.setWidget(0,0,new Label("Show only class diagrams containing classes named: (use * for wildcard)"));
    flexWildCard.setWidget(0,1,text_Wild_Card);
    text_Wild_Card.setWidth("200px");
    vpnlCheckBoxes.setWidth("200px");
    vpnlCheckBoxes.add(check_byPakag);
    vpnlCheckBoxes.add(check_Inheritance);
    vpnlCheckBoxes.add(check_byComposition);
    vpnlCheckBoxes.add(check_byDependency);
    hpnlWildCard.add(vpnlCheckBoxes);
    hpnlWildCard.add(flexWildCard);
    vpnl_Main.add(hpnlWildCard);
}

0 个答案:

没有答案