GWT异常:SimplePanel只能包含一个子窗口小部件

时间:2017-10-30 15:59:01

标签: java gwt frontend

以下ui.xml文件输出会引发异常

<g:HTMLPanel ui:field="uiPanelDialog" styleName="{CSS.common.flexContainerColumn} {style.content}">
    <g:Label ui:field="uiLabelTitle" styleName="{style.title}" text="What are you Looking for?"/>
    <g:HTMLPanel ui:field="uiPanelOptions" styleName="{style.scroll}">
        <g:FocusPanel ui:field="uiPanelWelcomeTutorial" styleName="{style.options}">
            <g:Image styleName="{style.image}" url="res/images/user_b.png" width="60px" height="60px" />
            <g:Label>Welcome Tutorial</g:Label>
        </g:FocusPanel>
        <g:FocusPanel ui:field="uiPanelGettingStarted" styleName="{style.options}">
            <g:Image styleName="{style.image}" url="res/images/user_b.png" width="60px" height="60px" />
            <g:Label>Getting Started</g:Label>
        </g:FocusPanel>
        <g:FocusPanel ui:field="uiPanelAppointmentManagement" styleName="{style.options}">
            <g:Image styleName="{style.image}" url="res/images/user_b.png" width="60px" height="60px" />
            <g:Label>Appointment Management</g:Label>
        </g:FocusPanel>
        <g:FocusPanel ui:field="uiPanelClientMangement" styleName="{style.options}">
            <g:Image styleName="{style.image}" url="res/images/user_b.png" width="60px" height="60px" />
            <g:Label>Client Mangement</g:Label>
        </g:FocusPanel>
        <g:FocusPanel ui:field="uiPanelStaffManagement" styleName="{style.options}">
            <g:Image styleName="{style.image}" url="res/images/user_b.png" width="60px" height="60px" />
            <g:Label>Staff Management</g:Label>
        </g:FocusPanel>
        <g:FocusPanel ui:field="uiPanelIntegrationSetup" styleName="{style.options}">
            <g:Image styleName="{style.image}" url="res/images/user_b.png" width="60px" height="60px" />
            <g:Label>Integration Setup</g:Label>
        </g:FocusPanel>
        <g:FocusPanel ui:field="uiPanelTechnicalSetup" styleName="{style.options}">
            <g:Image styleName="{style.image}" url="res/images/user_b.png" width="60px" height="60px" />
            <g:Label>Technical Setup</g:Label>
        </g:FocusPanel>
    </g:HTMLPanel>
    <g:HTMLPanel ui:field="uiPanelFooter">
        <g:FocusPanel ui:field="uiPanelGetHelpOnline" styleName="{style.options}" width="50%">
            <g:Label>Get Help Online</g:Label>
        </g:FocusPanel>
        <div class="{style.option-divider}" />
        <g:FocusPanel ui:field="uiPanelSendFeedback" styleName="{style.options}" width="50%">
            <g:Label>Send Feedback</g:Label>
        </g:FocusPanel>
    </g:HTMLPanel>

</g:HTMLPanel>

  

引起:java.lang.IllegalStateException:SimplePanel只能包含一个子窗口小部件

我无法弄清楚为什么会出现此异常。上述代码中存在的问题是什么。我想学习如何在焦点面板中放置不同的部分。

1 个答案:

答案 0 :(得分:2)

onDestroy

<g:FocusPanel ui:field="uiPanelWelcomeTutorial" styleName="{style.options}"> <g:Image styleName="{style.image}" url="res/images/user_b.png" width="60px" height="60px" /> <g:Label>Welcome Tutorial</g:Label> </g:FocusPanel> 扩展FocusPanel,只有一个孩子,正如您的错误告诉您的那样。我不确定你为什么要使用SimplePanel包裹这两个孩子,但是你不能这样做 - 只允许一个孩子在那里。如果您希望它们由于某种原因可以集中关注,请将FocusPanelImage放在一个容器中,然后将 放入Label