public class

SimplePanel

extends Panel
implements HasOneWidget
java.lang.Object
   ↳ com.google.gwt.user.client.ui.UIObject
     ↳ com.google.gwt.user.client.ui.Widget
       ↳ com.google.gwt.user.client.ui.Panel
         ↳ com.google.gwt.user.client.ui.SimplePanel
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Base class for panels that contain only one widget.

Summary

[Expand]
Inherited Constants
From class com.google.gwt.user.client.ui.UIObject
Public Constructors
SimplePanel()
Creates an empty panel that uses a DIV for its contents.
Protected Constructors
SimplePanel(Element elem)
Creates an empty panel that uses the specified browser element for its contents.
Public Methods
void add(Widget w)
Adds a widget to this panel.
Widget getWidget()
Gets the panel's child widget.
Iterator<Widget> iterator()
boolean remove(Widget w)
Removes a child widget.
void setWidget(IsWidget w)
Set the only widget of the receiver, replacing the previous widget if there was one.
void setWidget(Widget w)
Sets this panel's widget.
Protected Methods
Element getContainerElement()
Override this method to specify that an element other than the root element be the container for the panel's child widget.
[Expand]
Inherited Methods
From class com.google.gwt.user.client.ui.Panel
From class com.google.gwt.user.client.ui.Widget
From class com.google.gwt.user.client.ui.UIObject
From class java.lang.Object
From interface com.google.gwt.event.logical.shared.HasAttachHandlers
From interface com.google.gwt.event.shared.HasHandlers
From interface com.google.gwt.user.client.EventListener
From interface com.google.gwt.user.client.ui.AcceptsOneWidget
From interface com.google.gwt.user.client.ui.HasOneWidget
From interface com.google.gwt.user.client.ui.HasWidgets
From interface com.google.gwt.user.client.ui.HasWidgets.ForIsWidget
From interface com.google.gwt.user.client.ui.IsWidget
From interface java.lang.Iterable

Public Constructors

public SimplePanel ()

Creates an empty panel that uses a DIV for its contents.

Protected Constructors

protected SimplePanel (Element elem)

Creates an empty panel that uses the specified browser element for its contents.

Parameters
elem the browser element to use

Public Methods

public void add (Widget w)

Adds a widget to this panel.

Parameters
w the child widget to be added

public Widget getWidget ()

Gets the panel's child widget.

Returns
  • the child widget, or null if none is present

public Iterator<Widget> iterator ()

public boolean remove (Widget w)

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
w the widget to be removed
Returns
  • true if the child was present

public void setWidget (IsWidget w)

Set the only widget of the receiver, replacing the previous widget if there was one.

Parameters
w the widget, or null to remove the widget

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

Protected Methods

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. Note that this method continues to return the Element class defined in the User module to maintain backwards compatibility.

Returns
  • the element to be used as the panel's container