Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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

    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.ComplexPanel
                      com.google.gwt.user.client.ui.StackPanel

All Implemented Interfaces:
  EventListener, HasWidgets, IndexedPanel

    public class StackPanel

extends ComplexPanel

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

### CSS Style Rules

- .gwt-StackPanel { the panel itself }
- .gwt-StackPanel .gwt-StackPanelItem { unselected items }
- .gwt-StackPanel .gwt-StackPanelItem-selected { selected items }

### 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 new child with the given widget.
`void` | `add(Widget w, java.lang.String stackText)` Adds a new child with the given widget and header.
`void` | `add(Widget w, java.lang.String stackText, boolean asHTML)` Adds a new child with the given widget and header, optionally interpreting the header as HTML.
`int` | `getSelectedIndex()` Gets the currently selected child index.
`void` | `insert(Widget w, int beforeIndex)` Inserts a widget before the specified index.
`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 child by its index.
`void` | `setStackText(int index, java.lang.String text, boolean asHTML)` Sets the text associated with a child by its index.
`void` | `showStack(int index)` Shows the widget at the specified child index.

Methods inherited from class com.google.gwt.user.client.ui.ComplexPanel
`add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, getChildren, getWidget, getWidgetCount, getWidgetIndex, insert, insert, iterator`

Methods inherited from class com.google.gwt.user.client.ui.Panel
`adopt, adopt, clear, disown, doAttachChildren, doDetachChildren, onLoad, onUnload, orphan`

Methods inherited from class com.google.gwt.user.client.ui.Widget
`getParent, isAttached, onAttach, onDetach, removeFromParent, setElement`

Methods inherited from class com.google.gwt.user.client.ui.UIObject
`addStyleDependentName, addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, 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 new child with the given widget.

  Specified by:
    `add` in interface `HasWidgets`
  Overrides:
    `add` in class `Panel`
  Parameters:
    `w` - the widget to be added
  See Also:
    `HasWidgets.add(Widget)`

### add

    public void add(Widget w,
                    java.lang.String stackText)

  Adds a new child with the given widget and 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 new child with the given widget and 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

### getSelectedIndex

    public int getSelectedIndex()

  Gets the currently selected child index.

  Returns:
    selected child

### insert

    public void insert(Widget w,
                       int beforeIndex)

  Inserts a widget before the specified index.

  Parameters:
    `w` - the widget to be inserted
    `beforeIndex` - the index before which it will be inserted
  Throws:
    `java.lang.IndexOutOfBoundsException` - if `beforeIndex` is out of range

### 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`
  Parameters:
    `event` - the event received

### remove

    public boolean remove(int index)

  Description copied from interface: `IndexedPanel`
  Removes the widget at the specified index.

  Specified by:
    `remove` in interface `IndexedPanel`
  Overrides:
    `remove` in class `ComplexPanel`
  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 class: `Panel`
  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 `Panel.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`.

  Specified by:
    `remove` in interface `HasWidgets`
  Overrides:
    `remove` in class `ComplexPanel`
  Parameters:
    `child` - the widget to be removed
  Returns:
    `true` if the child was present

### setStackText

    public void setStackText(int index,
                             java.lang.String text)

  Sets the text associated with a child by its index.

  Parameters:
    `index` - the index of the child 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 child by its index.

  Parameters:
    `index` - the index of the child 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 child index.

  Parameters:
    `index` - the index of the child to be shown

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD