public class StackPanel extends ComplexPanel implements InsertPanel.ForIsWidget
This widget will only work in quirks mode. If your application is in
Standards Mode, use StackLayoutPanel instead.
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);
}
}
StackLayoutPanelUIObject.DebugIdImpl, UIObject.DebugIdImplEnabledInsertPanel.ForIsWidgetHasWidgets.ForIsWidgeteventsToSinkDEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR| Constructor and Description |
|---|
StackPanel()
Creates an empty stack panel.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Widget w)
Adds a child widget.
|
void |
add(Widget w,
SafeHtml stackHtml)
Adds a new child with the given widget and header, optionally interpreting
the header as HTML.
|
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.
|
void |
addHeaderStyleName(int index,
java.lang.String styleName)
Adds the
styleName on the <tr> for the header specified by index. |
(package private) Element |
createHeaderElem()
Returns a header element.
|
(package private) Element |
getHeaderTextElem(Element headerElem)
Get the element that holds the header text given the header element created
by #createHeaderElement.
|
int |
getSelectedIndex()
Gets the currently selected child index.
|
void |
insert(IsWidget w,
int beforeIndex) |
void |
insert(Widget w,
int beforeIndex)
Inserts a child widget before the specified index.
|
void |
onBrowserEvent(Event event)
Fired whenever a browser event is received.
|
protected void |
onEnsureDebugId(java.lang.String baseID)
Affected Elements:
-text# = The element around the header at the specified index.
-text-wrapper# = The element around the header at the specified index.
-content# = The element around the body at the specified index.
|
boolean |
remove(int index)
Removes the widget at the specified index.
|
boolean |
remove(Widget child)
Removes a child widget.
|
void |
removeHeaderStyleName(int index,
java.lang.String styleName)
Removes the
styleName off the <tr> for the header specified by index. |
void |
setStackText(int index,
SafeHtml html)
Sets the html associated with a child by its index.
|
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.
|
add, add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, doLogicalClear, getChildren, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, insert, iteratoradd, adopt, clear, doAttachChildren, doDetachChildren, orphan, removeaddAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, ensureHandlers, fireEvent, getHandlerCount, getHandlerManager, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onDetach, onLoad, onUnload, removeFromParent, replaceElement, setLayoutData, setParent, sinkEvents, unsinkEventsaddStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddgetWidgetIndexgetWidget, getWidgetCount, getWidgetIndexpublic void add(Widget w)
PanelHow to Override this Method
There are several important things that must take place in the correct order to properly add or insert a Widget to a Panel. Not all of these steps will be relevant to every Panel, but all of the steps must be considered.
ComplexPanel.adjustIndex(Widget, int).Widget.removeFromParent() on the
Widget.WidgetCollection at the appropriate index.Panel.adopt(Widget) to finalize the add as the
very last step.add in interface HasWidgetsadd in interface InsertPaneladd in class Panelw - the widget to be addedHasWidgets.add(Widget)public void add(Widget w, java.lang.String stackText)
w - the widget to be addedstackText - the header text associated with this widgetpublic void add(Widget w, SafeHtml stackHtml)
w - the widget to be addedstackHtml - the header html associated with this widgetpublic void add(Widget w, java.lang.String stackText, boolean asHTML)
w - the widget to be addedstackText - the header text associated with this widgetasHTML - true to treat the specified text as HTMLpublic int getSelectedIndex()
public void insert(IsWidget w, int beforeIndex)
insert in interface InsertPanel.ForIsWidgetpublic void insert(Widget w, int beforeIndex)
InsertPanelinsert in interface InsertPanelw - the child widget to be insertedbeforeIndex - the index before which it will be insertedpublic void onBrowserEvent(Event event)
EventListeneronBrowserEvent in interface EventListeneronBrowserEvent in class Widgetevent - the event receivedpublic boolean remove(int index)
IndexedPanelremove in interface IndexedPanelremove in class ComplexPanelindex - the index of the widget to be removedfalse if the widget is not presentpublic boolean remove(Widget child)
PanelHow 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.
false if it is not.Panel.orphan(Widget) first while the child
Widget is still attached.WidgetCollection.remove in interface HasWidgetsremove in class ComplexPanelchild - the widget to be removedtrue if the child was presentpublic void setStackText(int index,
java.lang.String text)
index - the index of the child whose text is to be settext - the text to be associated with itpublic void setStackText(int index,
SafeHtml html)
index - the index of the child whose text is to be sethtml - the html to be associated with itpublic void setStackText(int index,
java.lang.String text,
boolean asHTML)
index - the index of the child whose text is to be settext - the text to be associated with itasHTML - true to treat the specified text as HTMLpublic void showStack(int index)
index - the index of the child to be shownprotected void onEnsureDebugId(java.lang.String baseID)
onEnsureDebugId in class UIObjectbaseID - the base ID used by the main elementUIObject.onEnsureDebugId(String)Element createHeaderElem()
Element getHeaderTextElem(Element headerElem)
headerElem - the header elementpublic void addHeaderStyleName(int index,
java.lang.String styleName)
styleName on the <tr> for the header specified by index.index - the index of the header row to apply to the style tostyleName - the name of the class to addpublic void removeHeaderStyleName(int index,
java.lang.String styleName)
styleName off the <tr> for the header specified by index.index - the index of the header row to remove the style fromstyleName - the name of the class to remove