CheckBox代码不起作用没有编译时错误 [英] CheckBox Code Doesn't working there is no compile time error
问题描述
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。 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();
$ b $ else {
ToothWidget wgt = toothWidget.getTeeth()。getMap()。get(toothWidget.getToothNumber())。remove(menuItem.getName());
wgt.getPanel()。hide();
}
}
});
通常这是一个路径问题。即图像位置不是你正在设置的。
如果您的gwt模块的公共文件夹中包含图片文件夹,则需要使用 im.setUrl(GWT.getModuleBaseURL()+/ images /+ menuItem.getImg());
您的 war / images 需要使用
im.setUrl(GWT.getHostPageBaseURL()+/ images /+ menuItem.getImg()) ;
您也可以使用FireFox / FireBug的网络/图像控制台来检查正在访问的URL。
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();
}
}
});
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 use
im.setUrl(GWT.getHostPageBaseURL()+"/images/"+menuItem.getImg());
Also you can always use FireFox/FireBug's Network/Image console to check which URL is being accessed.
这篇关于CheckBox代码不起作用没有编译时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!