我是GWT的初學者。我想到了我的入門級如下:從eclipse執行GWT應用程序
public class HelloWorld implements EntryPoint {
public void onModuleLoad() {
// TODO Auto-generated method stub
Label label = new Label("Hello GWT !!!");
Button button = new Button("Say something");
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.alert("Hello, again");
}
});
try{
RootPanel.get("hold").add(label);
RootPanel.get("hold").add(button);
}catch(Exception e){
System.out.println(e.toString());
}
}
}
和XML文件來聲明入門級爲:
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='testgwt'>
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<!-- Specify the app entry point class -->
<entry-point class="com.jade.testgwt.client.HelloWorld"/>
</module>
HTML文件如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="TestGWT.css">
<title>My First GWT applicaton</title>
<script type="text/javascript" language="javascript" src="testgwt/test_gwt.nocache.js"></script>
</head>
<body>
<h1>My First GWT applicaton</h1>
<div id="hold"></div>
</body>
</html>
所以當我通過右鍵單擊該項目並選擇Run as Web應用程序運行時,我期待看到網頁上的標籤和按鈕控件。我只能看到h1的標籤文本。不知道爲什麼標籤和按鈕不顯示?
沒有解決問題。 – jade 2012-03-18 14:14:25