Google+ Followers

Wednesday, August 8, 2012

MGWT - A very simple example - click the button


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: )

4. And your EntryPoint will be this:

public class mobileEntryPoint implements EntryPoint {

    //global variables
    int countI;
    MTextBox lbl;
    public void onModuleLoad() {
                lbl = new MTextBox();
                //set viewport and other settings for mobile
                //build animation helper and attach it
                AnimationHelper animationHelper = new AnimationHelper();

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

                //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.


  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?

    1. Hi,
      Nice to help you. You can have more information on and Daniel's Kurka mailing list:!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:

    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?

    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.

    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.