com.google.gwt.user.client.ui
Class StackPanel

java.lang.Object
  extended bycom.google.gwt.user.client.ui.UIObject
      extended bycom.google.gwt.user.client.ui.Widget
          extended bycom.google.gwt.user.client.ui.Panel
              extended bycom.google.gwt.user.client.ui.ComplexPanel
                  extended bycom.google.gwt.user.client.ui.StackPanel
All Implemented Interfaces:
EventListener, HasWidgets, IndexedPanel

public class StackPanel
extends ComplexPanel
implements IndexedPanel

A panel that stacks its children vertically, displaying only one at a time, with a header for each that the user can click to display it.

CSS Style Rules

*

Example

public class StackPanelExample implements EntryPoint {

  public void onModuleLoad() {
    // Create a stack panel containing three labels.
    StackPanel panel = new StackPanel();
    panel.add(new Label("Foo"), "foo");
    panel.add(new Label("Bar"), "bar");
    panel.add(new Label("Baz"), "baz");

    // Add it to the root panel.
    RootPanel.get().add(panel);
  }
}


Constructor Summary
StackPanel()
          Creates an empty stack panel.
 
Method Summary
 void add(Widget w)
          Adds a widget to the stack.
 void add(Widget w, java.lang.String stackText)
          Adds a widget to the panel, along with its header.
 void add(Widget w, java.lang.String stackText, boolean asHTML)
          Adds a widget to the panel, along with its header, optionally interpreting the header as HTML.
 Widget getWidget(int index)
          Gets the child widget at the specified index.
 int getWidgetCount()
          Gets the number of child widgets in this panel.
 int getWidgetIndex(Widget child)
          Gets the index of the specified child widget.
 void onBrowserEvent(Event event)
          Fired whenever a browser event is received.
 boolean remove(int index)
          Removes the widget at the specified index.
 boolean remove(Widget child)
          Removes a child widget.
 void setStackText(int index, java.lang.String text)
          Sets the text associated with a widget, by its index.
 void setStackText(int index, java.lang.String text, boolean asHTML)
          Sets the text associated with a widget, by its index.
 void showStack(int index)
          Shows the widget at the specified index.
 
Methods inherited from class com.google.gwt.user.client.ui.ComplexPanel
add, getChildren, insert, iterator
 
Methods inherited from class com.google.gwt.user.client.ui.Panel
adopt, clear, disown, onAttach, onDetach
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached, onLoad, removeFromParent
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleName, getTitle, isVisible, isVisible, removeStyleName, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StackPanel

public StackPanel()
Creates an empty stack panel.

Method Detail

add

public void add(Widget w)
Adds a widget to the stack.

Specified by:
add in interface HasWidgets
Overrides:
add in class Panel
Parameters:
w - the widget to be added

add

public void add(Widget w,
                java.lang.String stackText)
Adds a widget to the panel, along with its header.

Parameters:
w - the widget to be added
stackText - the header text associated with this widget

add

public void add(Widget w,
                java.lang.String stackText,
                boolean asHTML)
Adds a widget to the panel, along with its header, optionally interpreting the header as HTML.

Parameters:
w - the widget to be added
stackText - the header text associated with this widget
asHTML - true to treat the specified text as HTML

getWidget

public Widget getWidget(int index)
Description copied from interface: IndexedPanel
Gets the child widget at the specified index.

Specified by:
getWidget in interface IndexedPanel
Parameters:
index - the child widget's index
Returns:
the child widget

getWidgetCount

public int getWidgetCount()
Description copied from interface: IndexedPanel
Gets the number of child widgets in this panel.

Specified by:
getWidgetCount in interface IndexedPanel
Returns:
the number of children

getWidgetIndex

public int getWidgetIndex(Widget child)
Description copied from interface: IndexedPanel
Gets the index of the specified child widget.

Specified by:
getWidgetIndex in interface IndexedPanel
Parameters:
child - the widget to be found
Returns:
the widget's index, or -1 if it is not a child of this panel

onBrowserEvent

public void onBrowserEvent(Event event)
Description copied from interface: EventListener
Fired whenever a browser event is received.

Specified by:
onBrowserEvent in interface EventListener
Overrides:
onBrowserEvent in class Widget

remove

public boolean remove(int index)
Description copied from interface: IndexedPanel
Removes the widget at the specified index.

Specified by:
remove in interface IndexedPanel
Parameters:
index - the index of the widget to be removed
Returns:
false if the widget is not present

remove

public boolean remove(Widget child)
Description copied from interface: HasWidgets
Removes a child widget.

Specified by:
remove in interface HasWidgets
Overrides:
remove in class ComplexPanel

setStackText

public void setStackText(int index,
                         java.lang.String text)
Sets the text associated with a widget, by its index.

Parameters:
index - the index of the widget whose text is to be set
text - the text to be associated with it

setStackText

public void setStackText(int index,
                         java.lang.String text,
                         boolean asHTML)
Sets the text associated with a widget, by its index.

Parameters:
index - the index of the widget whose text is to be set
text - the text to be associated with it
asHTML - true to treat the specified text as HTML

showStack

public void showStack(int index)
Shows the widget at the specified index.

Parameters:
index - the widget index to be shown