Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think your issue is with the way your ClickHandler is implemented as an anonymous inner class. At the point when <code>Test</code> method is executed, <code>this</code> has no meaning anymore. You need to rewrite your ClickHandler to hold an instance to your class:</p> <pre><code>public class testscan implements EntryPoint { public static class MyClickHandler implements ClickHandler { testscan instance; public MyClickHandler(testscan instance) { this.instance = instance; } public void onClick(ClickEvent event) { this.instance.x(); } } 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 MyClickHandler(this)); } public void x() { Test(this); } public native void Test(testscan instance) /*-{ instance.@com.sflpro.testscan.client.testscan::updateImageContent()(); }-*/; public void updateImageContent() { Window.alert("ok"); //String s = scanFileContent(); //Window.alert(s); if(image_0==null) Window.alert("bad"); else Window.alert("good"); } } </code></pre> <p>I mean this whole way you are going about it is a bit strange, but I understand you are just learning and this is just a test app you are playing around with. Normally you wouldn't have this type of code in your EntryPoint class.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload