Class StackPanel
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);
}
}
Constructors
Methods
Constructor Detail
StackPanel
public StackPanel()
Creates an empty stack panel.
Method Detail
add
Adds a new child with the given widget.
Parameters
- w
- the widget to be added
add
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
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.
Return Value
selected child
getWidget
public
Widget getWidget(
int index)
Gets the child widget at the specified index.
Parameters
- index
- the child widget's index
Return Value
the child widget
getWidgetCount
public int getWidgetCount()
Gets the number of child widgets in this panel.
Return Value
the number of children
getWidgetIndex
public int
getWidgetIndex(
Widget child)
Gets the index of the specified child widget.
Parameters
- child
- the widget to be found
Return Value
the widget's index, or
-1
if it is not a child of
this panel
onBrowserEvent
public void
onBrowserEvent(
Event event)
Parameters
- event
-
remove
public boolean remove(int index)
Removes the widget at the specified index.
Parameters
- index
- the index of the widget to be removed
Return Value
false
if the widget is not present
remove
public boolean
remove(
Widget w)
Parameters
- w
-
setStackText
public void
setStackText(
int index, 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, 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