Example usage for com.google.gwt.gwtai.applet.client AppletJSUtil registerAppletCallback

List of usage examples for com.google.gwt.gwtai.applet.client AppletJSUtil registerAppletCallback

Introduction

In this page you can find the example usage for com.google.gwt.gwtai.applet.client AppletJSUtil registerAppletCallback.

Prototype

public static void registerAppletCallback(Applet applet, AppletCallback<? extends Object> appletCallback) 

Source Link

Document

Registers an instance of your AppletCallback implementation to listen for callbacks coming from the given Applet.

Usage

From source file:com.google.gwt.gwtai.demo.client.GwtAI.java

License:Apache License

private Widget createCallbackApplet() {
    CallbackApplet applet = (CallbackApplet) GWT.create(CallbackApplet.class);
    Widget widgetAppletOne = AppletJSUtil.createAppletWidget(applet);
    RootPanel.get().add(widgetAppletOne);

    AppletJSUtil.registerAppletCallback(applet, new AppletCallback<String>() {
        public void callback(String callbackValue) {
            Window.alert("Received: " + callbackValue);
        }//from   w  w w.j  ava  2  s .  c  om
    });

    return widgetAppletOne;
}

From source file:com.google.gwt.gwtai.demo.client.StopWatchAppletTab.java

License:Apache License

public StopWatchAppletTab() {
    VerticalPanel panelMain = new VerticalPanel();
    panelMain.setWidth("100%");
    panelMain.setSpacing(4);//from  ww  w .  j a  v a 2  s.  c om

    VerticalPanel panelLaps = new VerticalPanel();
    panelLaps.setWidth("100%");
    panelLaps.setSpacing(4);

    Button buttonStart = new Button("Start");
    Button buttonStop = new Button("Stop");

    final StopWatchApplet stopWatchApplet = (StopWatchApplet) GWT.create(StopWatchApplet.class);

    buttonStart.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            stopWatchApplet.startWatch();
        }
    });

    buttonStop.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            stopWatchApplet.stopWatch();
        }
    });

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setSpacing(4);
    buttonPanel.add(buttonStart);
    buttonPanel.add(buttonStop);

    Widget widgetApplet = AppletJSUtil.createAppletWidget(stopWatchApplet);
    AppletJSUtil.registerAppletCallback(stopWatchApplet, new StopWatchCallback(panelLaps));

    Label labelTitle = new Label(
            "Register a callback object to notify GWT of changes from within the Applet code.");
    DisclosurePanel panelCode = new DisclosurePanel("View code");
    panelCode.setWidth("100%");
    panelCode.setAnimationEnabled(true);
    panelCode.setContent(createCodeHTML());

    panelMain.add(labelTitle);
    panelMain.add(widgetApplet);
    panelMain.add(buttonPanel);
    panelMain.add(panelLaps);
    panelMain.add(panelCode);

    panelMain.setCellHorizontalAlignment(labelTitle, VerticalPanel.ALIGN_CENTER);
    panelMain.setCellHorizontalAlignment(widgetApplet, VerticalPanel.ALIGN_CENTER);
    panelMain.setCellHorizontalAlignment(panelLaps, VerticalPanel.ALIGN_CENTER);
    panelMain.setCellHorizontalAlignment(buttonPanel, VerticalPanel.ALIGN_CENTER);

    initWidget(panelMain);
}