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.