问题
public SubMenuItemCommand(MenuObject menuItem,JsArray listOfMenu,ToothWidget toothWidget){ this.menuItem=menuItem; this.listOfMenu=listOfMenu; this.toothWidget=toothWidget; }
cb1.addClickHandler(new ClickHandler(){
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();
}
}
});
回答1:
Usually it is a path issue. i.e image location is not what you are setting up.
If you have images folder in your gwt module's public folder you need to use im.setUrl(GWT.getModuleBaseURL()+"/images/"+menuItem.getImg());
If you have images in your war/images you need to useim.setUrl(GWT.getHostPageBaseURL()+"/images/"+menuItem.getImg());
Also you can always use FireFox/FireBug's Network/Image console to check which URL is being accessed.
来源:https://stackoverflow.com/questions/14193435/checkbox-code-doesnt-working-there-is-no-compile-time-error