Gwt 复选框代码不为';没有编译时错误

Gwt 复选框代码不为';没有编译时错误,gwt,Gwt,公共子菜单项命令(MenuObject menuItem,JsArray listofMenus,ToothWidget ToothWidget){this.menuItem=menuItem;this.listofMenus=listofMenus;this.ToothWidget=ToothWidget;} cb1.addClickHandler(新的ClickHandler(){ 通常这是一个路径问题,即图像位置不是您要设置的 如果在gwt模块的公用文件夹中有图像文件夹,则需要使用im.s

公共子菜单项命令(MenuObject menuItem,JsArray listofMenus,ToothWidget ToothWidget){this.menuItem=menuItem;this.listofMenus=listofMenus;this.ToothWidget=ToothWidget;}

cb1.addClickHandler(新的ClickHandler(){


通常这是一个路径问题,即图像位置不是您要设置的

如果在gwt模块的公用文件夹中有图像文件夹,则需要使用
im.setUrl(gwt.getModuleBaseURL()+“/images/”+menuItem.getImg());

如果您的战争/图像中有图像,则需要使用
im.setUrl(GWT.getHostPageBaseURL()+“/images/”+menuItem.getImg());


此外,您还可以随时使用FireFox/FireBug的网络/图像控制台检查正在访问的URL。

WITE->发生了什么错误?没有错误bt menuItem.getImage()不工作…System.out.println(menuItem.getImage())不打印任何内容…出现弹出窗口bt中没有图像it@Override公共void onClick的注释(单击事件){…}是不是,不需要?!!你能澄清你的问题吗。很难阅读并添加一些关于你正在尝试做什么的信息。有一个复选框,如果我选中复选框,则必须出现包含图像的弹出框…toothwidget是另一个类…我在复选框上添加了clickhandler…我已经附加了快照…请参考它..i你用过你的建议bt不起作用
                public void onClick(ClickEvent event) {

                    System.out.println(menuItem.getImage());
                    boolean checked = ((CheckBox) event.getSource()).getValue();
                    if (checked) {
                        System.out.println("hello3");
                        int left = toothWidget.getToothImage().getAbsoluteLeft();
                        int top =  toothWidget.getVPanel().getAbsoluteTop();//toothWidget.getToothImage().getAbsoluteTop();
                        Image im = new Image();
                        im.setUrl("images/"+menuItem.getImg());
                        int offx = left;
                        int offy = top;     
                        final PopupPanel popup1 = new PopupPanel(true);
                        popup1.setStylePrimaryName("transparent");
                        popup1.setPopupPosition(Math.max(offx, 0),Math.max(offy, 0));
                        //popup.add(im);
                        ToothWidget wgt = new ToothWidget(toothWidget.getToothNumber(),menuItem.getImg(), toothWidget.getTeeth());
                        toothWidget.getTeeth().getMap().get(toothWidget.getToothNumber()).put(menuItem.getName(), wgt);
                        wgt.setMenu(toothWidget.getMenu());
                        wgt.setPanel(popup1);
                        popup1.add(wgt);
                        popup1.show();
                    }

                    else{
                        ToothWidget wgt = toothWidget.getTeeth().getMap().get(toothWidget.getToothNumber()).remove(menuItem.getName());
                        wgt.getPanel().hide();
                    }
                }
             });