/**
* This is the entry point method.
*/
public void onModuleLoad() {
Canvas canvas = Canvas.createIfSupported();
final Context2d context2d = canvas.getContext2d();
RootPanel.get("canvas").add(canvas);
Image img = new Image("face.png");
final ImageElement face = ImageElement.as(img.getElement());
img.addLoadHandler(new LoadHandler() {
@Override
public void onLoad(LoadEvent event) {
context2d.drawImage(face, 0, 0);
}
});
//RootPanel.get("canvas").add(img);
}
이것은 내 코드입니다. 캔버스에 이미지를 그려야합니다. 마지막 줄이있는 경우 작동합니다.GWT 캔버스 2D 그리기 이미지
RootPanel.get ("canvas"). add (img);
은 주석 처리되지 않았습니다.
줄을 주석 처리하면 이미지가로드되지 않는 것처럼 보입니다. 어떤 아이디어?
이것은 img.setVisible (false); onLoad 내부. – Craigo