Putting Urself into GWT-GoogleWebToolkit
April 11th, 2008Setup First Application
The Java FileÂ
package com.mycompany.client;
import com.google.gwt.user.client.Window;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
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.Widget;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class MyApplication implements EntryPoint {
/**
* This is the entry point method.
*/
public void onModuleLoad() {
final Button moredetails = new Button(“Details”);
final Button button = new Button(“Register me”);
final Label label = new Label();
final CheckBox cb = new CheckBox(“I Agree with the terms and condition applied by the AppBox”);cb.setChecked(true);
cb.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
boolean checked = ((CheckBox) sender).isChecked();Window.alert(
“It is “ + (checked ? “” : “not”) + “checked”);
}
});
moredetails.addClickListener(new ClickListener() {
public void onClick(Widget sender) {Window.alert(
“How high?”);
}
});
button.addClickListener(new ClickListener() {public void onClick(Widget sender) { if (label.getText().equals(“”)) label.setText(“Hello World!”);
else
label.setText(“”);
}
});
// Assume that the host HTML has elements defined whose
// IDs are “slot1″, “slot2″. In a real app, you probably would not want
// to hard-code IDs. Instead, you could, for example, search for all
// elements with a particular CSS class and replace them with widgets.
//
RootPanel.get(“slot4″).add(cb);
RootPanel.get(“slot3″).add(moredetails);RootPanel.get(
“slot1″).add(button);RootPanel.get(“slot2″).add(label);
}
}
The HTML fileÂ
<html>
<head>
<!– –>
<!– Any title is fine –>
<!– –>
<title>First App</title>
<!– –>
<!– Use normal html, such as style –>
<!– –>
<style>
body,td,a,div,.p{font-family:arial,sans-serif}
div,td{color:#000000}
a:link,.w,.w a:link{color:#0000cc}
a:visited{color:#551a8b}
a:active{color:#ff0000}
</style>
<!– –>
<!– This script loads your compiled module. –>
<!– If you add any GWT meta tags, they must –>
<!– be added before this line. –>
<!– –>
<script language=‘javascript’ src=‘com.mycompany.MyApplication.nocache.js’></script>
</head>
<!– –>
<!– The body can have arbitrary html, or –>
<!– you can leave the body empty if you want –>
<!– to create a completely dynamic ui –>
<!– –>
<body>
<!– OPTIONAL: include this if you want history support –>
<iframe src=“javascript:””
<h1>App Box</h1>
<h3>FirstApp</h3>
<p>
Ok guys i know u people are getting bored off by wasting time on the ____.
Now AppBox solves most of your problems and gives YOU the control at your HANDHELD device
</p>
<table align=center>
<tr>
<td
</tr>
<tr>
<td
<td
</tr>
<tr>
<td
</tr>
</table>
</body>
</html>
This cup of tea was served by: Qasim Ali Khawaja’s Weblog














Have your say,We have no comments yet.