public class WidgetCollection extends java.lang.Object implements java.lang.Iterable<Widget>
panels and
composites.
The main purpose of this specialized collection is to implement
Iterator.remove() in a way that delegates removal to its
panel. This makes it much easier for the panel to implement an
iterator that
supports removal of widgets.
| Constructor and Description |
|---|
WidgetCollection(HasWidgets parent)
Constructs a new widget collection.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Widget w)
Adds a widget to the end of this collection.
|
boolean |
contains(Widget w)
Determines whether a given widget is contained in this collection.
|
Widget |
get(int index)
Gets the widget at the given index.
|
int |
indexOf(Widget w)
Gets the index of the specified index.
|
void |
insert(Widget w,
int beforeIndex)
Inserts a widget before the specified index.
|
java.util.Iterator<Widget> |
iterator()
Gets an iterator on this widget collection.
|
void |
remove(int index)
Removes the widget at the specified index.
|
void |
remove(Widget w)
Removes the specified widget.
|
int |
size()
Gets the number of widgets in this collection.
|
public WidgetCollection(HasWidgets parent)
parent - the container whose HasWidgets.remove(Widget) will be
delegated to by the iterator's Iterator.remove() method.public void add(Widget w)
w - the widget to be addedpublic boolean contains(Widget w)
w - the widget to be searched fortrue if the widget is presentpublic Widget get(int index)
index - the index to be retrievedjava.lang.IndexOutOfBoundsException - if the index is out of rangepublic int indexOf(Widget w)
w - the widget to be found-1 if it is
not foundpublic void insert(Widget w, int beforeIndex)
w - the widget to be insertedbeforeIndex - the index before which the widget will be insertedjava.lang.IndexOutOfBoundsException - if beforeIndex is out of
rangepublic java.util.Iterator<Widget> iterator()
HasWidgets.iterator in interface java.lang.Iterable<Widget>public void remove(int index)
index - the index of the widget to be removedjava.lang.IndexOutOfBoundsException - if index is out of rangepublic void remove(Widget w)
w - the widget to be removedjava.util.NoSuchElementException - if the widget is not presentpublic int size()