簡體   English   中英

SimplePanel和子小部件

[英]SimplePanel and child widgets

我對SimplePanel及其子小部件有疑問。 我正在捕捉以下異常

SimplePanel can contain one child widget

在我的代碼中,從SimplePanel繼承的唯一元素是ScrollPanel,其用法如下:

scroll = new ScrollPanel();
scroll.add(internalVerticalPanel);
internalVerticalPanel2.add(scroll);

“ internalVerticalPanel”對象由Horizo​​ntalPanel和Labels組成。 這種組合不可能嗎?

提前非常感謝,問候

就像例外所述-您只能向SimplePanel容器(及其子類,如ScrollPanelFormPanel )添加一個孩子。 來自異常的stacktrace應該指出添加第二個孩子的位置。

至於問題的第二部分, SimplePanel的(一個)孩子本身可以有多個孩子(如果其實現允許)。 因此,您顯示給我們的代碼應該可以按預期的方式工作-行為不當的是您沒有顯示給我們的代碼;)

還行吧:

Whatever container
|_ ScrollPanel
   |_FlowPanel  <- the only direct child of ScrollPanel
     |_SimplePanel
     |_TextBox
     |_ScrollPanel
     |_FlowPanel
     |_ScrollPanel

這似乎是您的情況:

ScrollPanel
|_ChildWidget1 <- child number 1 of ScrollPanel
| |_TextBox
| |_TextBox
| |_Label
|_ChildWidget2 <- child number 2 of ScrollPanel -> error!

ChildWidget1可以有多ChildWidget1 (只要它支持多個子級-例如,它是FlowPanel )就可以了。 ScrollPanel具有多個直接子代是錯誤的: ChildWidget1 ChildWidget2

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM