Panel.getWidgetCount no longer available in 1.1?

24 views
Skip to first unread message

Eric B

unread,
Aug 11, 2006, 11:35:39 PM8/11/06
to Google Web Toolkit
So com.google.gwt.user.client.ui.Panel implements the interface
com.google.gwt.user.client.ui.HasWidgets which has the methods:

void add(Widget w)
void clear()
java.util.Iterator iterator()
boolean remove(Widget w)

But there is no way, other than looping through using the iterator, to
figure out how many child widgets a panel has? What's up with that?
This is a bug, right? I'm not going crazy?

Thanks,
Eric

Mat Gessel

unread,
Aug 12, 2006, 12:31:07 AM8/12/06
to Google-We...@googlegroups.com
Looks like getWidgetCount() was factored into the IndexedPanel interface.

I would like to see getWidgetCount() implemented in ComplexPanel since
getChildren() is protected.

-= Mat

--
Mat Gessel
http://www.asquare.net

Vivian

unread,
Aug 12, 2006, 12:57:49 AM8/12/06
to Google Web Toolkit
Eric:

The previous Panel did not have a getWidgetCount method. Some panels do
not contain more than one child element, some panels do. Some panels
implement HasWidgets, some implement IndexedPanel, and some return
WidgetCollection which has a getSize() method.

Here are the classes in the 1.1 release that implement IndexedPanel

DeckPanel, FlowPanel, HorizontalPanel, StackPanel, TabPanel,
VerticalPanel

and subclasses of those.

The following classes extend ComplexPanel and therefore you can obtain
the size via getChildren().size():

AbsolutePanel, HTMLPanel

and subclasses of those.

-Vivian
GWT Team

Vivian

unread,
Aug 12, 2006, 1:01:56 AM8/12/06
to Google Web Toolkit

Just to follow up, I forgot to add that you can't use getChildren()
unless you extend ComplexPanel(or HTMLPanel/AbsolutePanel) in order to
call getChildren().

-Vivian
GWT Team

Eric B

unread,
Aug 12, 2006, 3:00:05 AM8/12/06
to Google Web Toolkit
Thanks for clarifying. However, in 1.0.21 I was able to call
PopupPanel.getWidgetCount() and now I have to loop through the iterator
to get the count. It seems like getWidgetCount() should be a method of
the HasWidgets interface.

Thanks,
Eric

IamRobe...@gmail.com

unread,
Aug 12, 2006, 7:38:22 AM8/12/06
to Google Web Toolkit
> in 1.0.21 I was able to call PopupPanel.getWidgetCount()

I think you may be thinking of a different class. The PopupPanel can
only hold a single widget. There is no real reason to iterate over the
children, just call getWidget().

Rob

Reply all
Reply to author
Forward
0 new messages