我是 GWT 和 Java 的新手。
我尝试通过 GWT 和其中的 UI 元素创建一个 DockLayoutPanel。
但它失败了,我收到了错误消息:
[错误] [MainPage] - 无法加载模块入口点类 com.Test.MainPage(有关详细信息,请参阅相关异常)
java.lang.AssertionError:具有现有父小部件的小部件可能不会添加到 com.google.gwt.user.client.ui.RootPanel.detachOnWindowClose(RootPanel.java:138) 的分离列表中
MyDockLayoutPanel.ui.xml 中的一些内容
<g:DockLayoutPanel unit='EM'>
<g:north size='5'>
<g:FlowPanel styleName="{style.northPanel}">
<g:Label>This is the NORTH panel</g:Label>
</g:FlowPanel>
</g:north>
<g:west size='15'>
<g:FlowPanel styleName="{style.westPanel}">
<g:Label>This is the WEST panel</g:Label>
</g:FlowPanel>
</g:west>
<g:center>
<g:FlowPanel styleName="{style.centerPanel}">
<g:Label>This is the CENTER panel</g:Label>
<g:HTML>
<h1>Web Application Starter Project</h1>
<table align="center">
<tr>
<td colspan="2" style="font-weight:bold;">Please enter your name:</td>
</tr>
<tr>
<td id="nameFieldContainer"></td>
<td id="sendButtonContainer"></td>
</tr>
<tr>
<td colspan="2" style="color:red;" id="errorLabelContainer"></td>
</tr>
</table>
</g:HTML>
</g:FlowPanel>
</g:center>
</g:DockLayoutPanel>
MainPage.java 中的一些内容
public void onModuleLoad() {
SGCDockLayoutPanel p = new SGCDockLayoutPanel();
RootLayoutPanel.get().add(p);
final Button sendButton = new Button("Send");
final TextBox nameField = new TextBox();
nameField.setText("GWT User");
final Label errorLabel = new Label();
// We can add style names to widgets
sendButton.addStyleName("sendButton");
// Add the nameField and sendButton to the RootPanel
Use RootPanel.get() to get the entire body element
RootPanel.get("nameFieldContainer").add(nameField);
RootPanel.get("sendButtonContainer").add(sendButton);
RootPanel.get("errorLabelContainer").add(errorLabel);
}