Hi I have the following strange issue:
I have gwt application. it contains 3 image widgets and a button. on Button click I am calling function X() and then inside X I am calling Test(testscan instance) by passing instance to the Javascript function.
现在看着试验功能。 我试图把 Java称为“最新消息”的职能从那里传来。 The syntax written at GWT documentation.
When I run the application the instance of "testscan" class is Null what can be the reason?
public class testscan implements EntryPoint {
private Image image_0 = new Image("home.gif");
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get("main_panel");
rootPanel.getElement().getStyle().setPosition(Position.RELATIVE);
VerticalPanel verticalPanel = new VerticalPanel();
rootPanel.add(verticalPanel, 5, 5);
verticalPanel.setSize("100%", "100%");
HorizontalPanel horizontalPanel = new HorizontalPanel();
verticalPanel.add(horizontalPanel);
horizontalPanel.setSize("100%", "100%");
Image image_1 = new Image("home.gif");
horizontalPanel.add(image_1);
image_1.setSize("180px", "180px");
horizontalPanel.add(image_0);
image_0.setSize("180px", "180px");
Image image_2 = new Image("home.gif");
horizontalPanel.add(image_2);
image_2.setSize("180px", "180px");
Button btnScan = new Button("Scan");
verticalPanel.add(btnScan);
btnScan.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
x();
}
});
}
public void x()
{
Test(this);
}
public native void Test(testscan instance) /*-{
[email protected]::updateImageContent()();
}-*/;
public void updateImageContent()
{
Window.alert("ok");
//String s = scanFileContent();
//Window.alert(s);
if(image_0==null)
Window.alert("bad");
else
Window.alert("good");
}