A)您需要將HelloWorld.ui.xml
文件放在與包含該ui.xml文件的邏輯的小部件類相同的包中。類名應該是HelloWorld
(爲了簡單起見,我說你需要使用相同的名稱,但可以通過代碼爲ui.xml文件使用不同的名稱)。
B)您的HelloWorld
類應該是一個擴展小部件的類。就像任何'普通'小部件一樣,它可以添加到任何面板。
這裏是綁定HelloWorld.ui.xml
在你HelloWorld
控件類的代碼:
public class HelloWorld extends Composite /*or extend any widget you want*/ {
//This defines an interface that represents this specific HelloWorld.ui.xml file.
interface MyUiBinder extends UiBinder<Widget, HelloWorld> {}
// This code is for GWT so it can generate the code from your HelloWorld.ui.xml
private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
//Constructor
public HelloWidgetWorld() {
// This binds the HelloWorld.ui.xml with this widget
initWidget(uiBinder.createAndBindUi(this));
...
}
...
}
另外,安裝[Google Plugin for Eclipse](http://code.google.com/eclipse/),它將處理大部分工作(您只需放置組件名稱,它將創建相應的java和ui.xml文件).... [其他事項](http://code.google.com/eclipse/docs/gwt.html):) – 2011-01-29 13:19:45