I'm using GWT 2.4. Given a com.google.gwt.user.client.ui.Widget, how do I get the first child widget? For example, if the Widget represents a <div>
, I'd like to know the first thing within the <div>
. There is no guarantee that there will be a child widget, but if there is, I'd like to know how to get it.
All I know is this generic object class. I'm not guaranteed that this will be a widget like a FlowPanel or anything else, even though those are possibilities.
GWT widgets that can have children implement the HasWidgets
interface:
Widget getFirstChild(Widget parent) {
if (parent instanceof HasWidgets) {
Iterator<Widget> iter = ((HasWidgets) parent).iterator();
return (iter != null && iter.hasNext()) ? iter.next() : null;
}
return null;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With