How to integrate GWT UIBinder with Canvas?

后端 未结 1 1533
故里飘歌
故里飘歌 2021-01-24 05:32

I am trying to find my way around with the Google Web Toolkit. Right now I am trying to get a Canvas widget up and running.

But I am getting this error and

1条回答
  •  太阳男子
    2021-01-24 06:38

    You cannot create a Canvas with the UI:Binder, because there is no zero-arg constructor, nor a @UIConstructor.

    I would suggst to create a warpper (A simplePanel) and within your Wrapper-Code, you can create a Canvas, by calling Canvas.createIfSupported():

    The canvas itself is prvided.

     @UiField(provided = true)
     Canvas canvas;
    

    Before you call binder.createAndBindUi(this); you will have to create the Canvas:

    canvas = Canvas.createIfSupported()
    

    I have no simple example, but maybe, this link is helpful: https://code.google.com/p/gwtgae2011/source/browse/src/main/java/com/googlecode/gwtgae2011/client/main/SketchView.java?r=8e7169e7fbb411f320f99f77dcdb27efa27b727a

    You also could use a CanvasElement, like described in this question: GWT uibinder CanvasElement wont resize when deployed

    0 讨论(0)
提交回复
热议问题