Class SimplePanel

public class SimplePanel
extends Panel

// Superclass of FocusPanel, FormPanel, PopupPanel, ScrollPanel
Abstract base class for panels that contain only one widget.

Constructors

SimplePanel()Creates an empty panel that uses a DIV for its contents.
SimplePanel(Element)Creates an empty panel that uses the specified browser element for its contents.

Methods

add(Widget)Adds a widget to this panel.
getContainerElement()Override this method to specify that an element other than the root element be the container for the panel's child widget.
getWidget()Gets the panel's child widget.
iterator()Gets an iterator for the contained widgets.
remove(Widget)Removes a child widget.
setWidget(Widget)Sets this panel's widget.

Constructor Detail

SimplePanel

public SimplePanel()
Creates an empty panel that uses a DIV for its contents.

SimplePanel

protected SimplePanel(Element elem)
Creates an empty panel that uses the specified browser element for its contents.

Parameters

elem
the browser element to use

Method Detail

add

public void add(Widget w)
Adds a widget to this panel.

Parameters

w
the child widget to be added

getContainerElement

protected Element getContainerElement()
Override this method to specify that an element other than the root element be the container for the panel's child widget. This can be useful when you want to create a simple panel that decorates its contents.

Return Value

the element to be used as the panel's container

getWidget

public Widget getWidget()
Gets the panel's child widget.

Return Value

the child widget, or null if none is present

iterator

public Iterator iterator()
Gets an iterator for the contained widgets. This iterator is required to implement Iterator.remove().

remove

public abstract boolean remove(Widget child)
Removes a child widget.

How to Override this Method

There are several important things that must take place in the correct order to properly remove a Widget from a Panel. Not all of these steps will be relevant to every Panel, but all of the steps must be considered.

  1. Validate: Make sure this Panel is actually the parent of the child Widget; return false if it is not.
  2. Orphan: Call orphan(Widget) first while the child Widget is still attached.
  3. Physical Detach: Adjust the DOM to account for the removal of the child Widget. The Widget's Element must be physically removed from the DOM.
  4. Logical Detach: Update the Panel's state variables to reflect the removal of the child Widget. Example: the Widget is removed from the Panel's WidgetCollection.

Parameters

child
the widget to be removed

Return Value

true if the child was present

setWidget

public void setWidget(Widget w)
Sets this panel's widget. Any existing child widget will be removed.

Parameters

w
the panel's new widget, or null to clear the panel