Pages

Google+ Followers

Wednesday, August 8, 2012

MGWT - A very simple example - click the button

MGWT

MGWT stands for developing mobile applications with GWT and mgwt.
Mgwt works on all kind of mobile devices that support webkit (like iPhone, iPad, iPod, Android, Blackberry, ...)
  • Native support for touchevent the GWT Way
  • Animations built in with GWT MVP
  • lots and lots of widgets
  • specific theme for each plattform (iOS, Android, ...)

 Let' se a simple example starting from a Google Web Toolkit(GWT) project:

1. Create a GWT project
2. In your gwt xml file add this line:
   <inherits name='com.googlecode.mgwt.MGWT'/>

3. Add the MGWT library to your project
(It can be downloaded from: http://www.m-gwt.com/ )

4. And your EntryPoint will be this:


public class mobileEntryPoint implements EntryPoint {

    //global variables
    int countI;
    MTextBox lbl;
   
    public void onModuleLoad() {
                //initialization
                lbl = new MTextBox();
                countI=0;
       
                //set viewport and other settings for mobile
                MGWT.applySettings(MGWTSettings.getAppSetting());
                //build animation helper and attach it
                AnimationHelper animationHelper = new AnimationHelper();
                RootPanel.get().add(animationHelper);

                //build some UI
                LayoutPanel layoutPanel = new LayoutPanel();
                Button button = new Button("Hello User!");               
                //for click event
                button.addTapHandler(new TapHandler() {
                    @Override
                    public void onTap(TapEvent event) {
                        countI++;                                               
                        lbl.setText("You clicked: "+countI+" times");
                    }                   
                }) ;                                                                                             
                layoutPanel.add(button);
                layoutPanel.add(lbl);

                //animate at click
                animationHelper.goTo(layoutPanel, Animation.SLIDE);              
    }
}

By using gwt-phonegap and mgwt you can write applications that can be deployed into the app store or the market place with GWT.

5 comments:

  1. Hi Lehel,

    Very nice and simple demo. Best for a newbie like me. Thank you.
    I have been following your blog posts, but I miss a simple demo explaining how I can add gwt-phonegap so that I can deploy the app into playstore/market place?

    ReplyDelete
    Replies
    1. Hi,
      Nice to help you. You can have more information on http://www.m-gwt.com/ and Daniel's Kurka mailing list: https://groups.google.com/forum/?fromgroups#!forum/mgwt

      I wrote some downloadable examples too, simple demo projects written under Netbeans Ide, related to gwt-phonegap too. You can use this for free: http://siposlehel.atw.hu

      Delete
    2. Thank you for your response. I have been following Daniels mailing list and also your demo examples for gwt-phonegap. I failed to convert the netbeans project to an eclipse one. Any pointers would be great help?

      Delete
    3. I think you should concentrate more on source code then converting it to Eclipse, and use the source in a new project created with Eclipse. Under Netbeans there is a possibility to import projects from Eclipse, look for such a plugin under Eclipse too. But anyway the source directory is the main.

      Delete
    4. With mgwt and gwt-phonegap you can deploy your GWT apps into any app store or let your users use them as a website. Both projects are available under apache 2.0 license from maven central.

      Delete