0

单击图像时,我试图弹出一个窗口。下面是一段代码:

while(index<bookList.size()){
        if(cellCount<4){
            image[index] = new Image(imageList.get(index));
            final int imageIndex = index;
            table.setWidget(row, cellCount, new Image(bookList.get(index)));
            table.addClickHandler(new ClickHandler(){

                @Override
                public void onClick(ClickEvent event) {
                    VerticalPanel vPanel = new VerticalPanel();
                    vPanel = imageDetail.getPopup(popup, image[imageIndex]);
                    popup.setAnimationEnabled(true);
                    popup.setGlassEnabled(true);
                    popup.setAutoHideEnabled(false);
                    popup.setWidth("300px");
                    popup.setHeight("300px");
                    popup.add(vPanel);
                    popup.center();
                }});
            table.getFlexCellFormatter().setStyleName(row, cellCount, "ImageCell");
            cellCount++;
            index++;
        }

上面的代码包含 clickhandler,它调用 imageDetail 对象的“getPopup”。“getPopup”函数返回一个添加到 PopupPanel 的垂直面板。ImageDetail类如下

public class ImageDetails extends Composite {
private Image closeButton;

VerticalPanel getPopup(final PopupPanel popup, Image image){
    VerticalPanel vPanel = new VerticalPanel();

    //Close Button
    HorizontalPanel closePanel = new HorizontalPanel();
    closeButton = new Image("/Images/closebutton.jpg");
    closeButton.addClickHandler(new ClickHandler(){

        @Override
        public void onClick(ClickEvent event) {
            // TODO Auto-generated method stub
            popup.hide();

        }});
    closePanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    closePanel.add(closeButton);
    vPanel.add(closePanel);

    VerticalPanel imagePanel = new VerticalPanel();
    imagePanel.add(image);
    vPanel.add(imagePanel);

    return vPanel;

}

我的问题如下:1)可以从函数返回面板吗?如果不是,那为什么?如果是,为什么上面的代码给出“Uncaught exception escaped com.google.gwt.event.shared.UmbrellaException: 3 exceptions mapped: null; null; null”?

2)当我尝试在“getPopup”函数中将垂直面板添加到弹出面板并从那里获取弹出面板时,代码返回与第一个问题中提到的相同的错误。我错过了什么?

我错过了任何 initWidget(w) 函数调用吗?

谢谢

4

0 回答 0