Netbeans:NetbeansGWTModule
From Adapt
Creating a GWT Module
Hello world now done in GWT style. Instead of a static 'Hello World' page, a button will be placed on the web page that will display 'Hello World' when clicked.
Create a package under the root package called client. In that package, create a Java class named ModuleNameApp (e.g., HelloWorldApp.java). Put in the following code:
package edu.umiacs.gwt.hello.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.ClickListener; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; public class HelloWorldApp implements EntryPoint { public void onModuleLoad() { GWT.log("onModuleLoad()", null); final Label lblSayHello = new Label(); Button btnAsk = new Button("Say something"); btnAsk.addClickListener(new ClickListener() { public void onClick(Widget w) { lblSayHello.setText("Hello world!"); } }); VerticalPanel vp = new VerticalPanel(); vp.add(btnAsk); vp.add(lblSayHello); RootPanel root = RootPanel.get("div1"); root.add(vp); } }
Now modify the ModuleName.gwt.xml file (e.g., HelloWorld.gwt.xml) so that it now looks like this:
<?xml version="1.0" encoding="UTF-8"?> <module> <inherits name="com.google.gwt.user.User"/> <entry-point class="edu.umiacs.gwt.hello.client.HelloWorldApp"/> </module>
The entry-point element should specify the fully qualified path to the class which implements EntryPoint. Now place the necessary information in the ModuleName.html file (e.g., =HelloWorld.html=). It should now contain the following:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <meta name='gwt:module' content='edu.umiacs.gwt.hello.HelloWorld'> </head> <body> <script language="javascript" src="gwt.js"></script> <div id="div1"></div> </body> </html>
Run the project and click away!
Note: During development, first run the project to bring up the shell. From that point on, it is not necessary to re-run the project on any changes. After making changes to the html or java files, just do a build (or even quicker--save all files) and reload in the GWT browser window.
For more information: GWT Tutorial 2