Java GWT可以';不能在现有元素上定义画布
我有一个定义为Java GWT可以';不能在现有元素上定义画布,java,eclipse,gwt,canvas,Java,Eclipse,Gwt,Canvas,我有一个定义为HTML元素的元素,即。我试着这样画: import com.google.gwt.dom.client.Element; import com.google.gwt.user.client.DOM; Canvas canvas2 = Canvas.createIfSupported(); Element el = DOM.getElementById("foo"); canvas2.setElement(el); 最后一行在Eclipse中抛出了一个错误,错误消息为,来自UIO
HTML
元素的元素,即
。我试着这样画:
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
Canvas canvas2 = Canvas.createIfSupported();
Element el = DOM.getElementById("foo");
canvas2.setElement(el);
最后一行在Eclipse中抛出了一个错误,错误消息为,来自UIObject类型的方法setElement(Element)不可见。我应该怎么做来纠正它?这是我正在导入的类的列表,是否存在任何JAR
冲突
import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.canvas.dom.client.Context2d;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
不幸的是,目前没有简单的方法可以做到这一点。在GWT的问题跟踪程序中对此是开放的。建议的解决方法是复制Canvas小部件类并释放构造函数的可见性。。。我承认不太方便。不幸的是,目前没有简单的方法可以做到这一点。在GWT的问题跟踪程序中对此是开放的。建议的解决方法是复制Canvas小部件类并释放构造函数的可见性。。。我承认不太方便。在类路径中很可能存在一些JAR冲突。确保没有重复的JAR(在Eclipse项目库和运行时类路径中)。GWT中Canvas的方法setElement()受保护,因此访问它时可能会遇到问题,因此如何访问定义为HTML的
Canvas
元素,用GWT开发的一个好方法是完全避免javascript和HTML。。。您只使用Java代码(甚至用于构建UI结构)。这样,您几乎不需要按Id查询元素。在类路径中很可能存在一些JAR冲突。确保没有重复的JAR(在Eclipse项目库和运行时类路径中)。GWT中Canvas的方法setElement()受保护,因此访问它时可能会遇到问题,因此如何访问定义为HTML的Canvas
元素,用GWT开发的一个好方法是完全避免javascript和HTML。。。您只使用Java代码(甚至用于构建UI结构)。这样,您几乎不需要按Id查询元素。