如何在gwt ui-binder中添加画布?

时间:2012-12-14 14:17:18

标签: java gwt uibinder java-canvas

我有一个基本的ui-binder布局文件,并希望将画布放入主要内容区域。

但使用以下内容会出错:

No class matching "canvas" in urn:import:com.google.gwt.canvas.client: <c:canvas ui:field='canvas'>

我的消息来源有什么问题?

.ui.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
    xmlns:g='urn:import:com.google.gwt.user.client.ui'
    xmlns:c='urn:import:com.google.gwt.canvas.client'>
    <g:DockLayoutPanel>
    <!-- other stuff... ->

        <g:center>
            <c:canvas ui:field="canvas" />
        </g:center>
    </g:DockLayoutPanel>
</ui:UiBinder>

的.java:

@UiField//(provided = true)
Canvas canvas;

@Override
public void onModuleLoad() { 
    canvas = Canvas.createIfSupported();
    canvas.setWidth("400px");
    canvas.setHeight("400px"); 
    canvas.setCoordinateSpaceWidth(400);
    canvas.setCoordinateSpaceHeight(400);
}

1 个答案:

答案 0 :(得分:1)

OMG uibuilder中的canvas元素必须以大写字母开头......

<c:Canvas...