|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.Composite
com.google.gwt.user.client.ui.ResizeComposite
com.google.gwt.user.client.ui.TabLayoutPanel
public class TabLayoutPanel
A panel that represents a tabbed set of pages, each of which contains another widget. Its child widgets are shown as the user selects the various tabs associated with them. The tabs can contain arbitrary text, HTML, or widgets.
This widget will only work in standards mode, which requires that the HTML page in which it is run have an explicit <!DOCTYPE> declaration.
public class TabLayoutPanelExample implements EntryPoint { public void onModuleLoad() { // Create a three-item tab panel, with the tab area 1.5em tall. TabLayoutPanel p = new TabLayoutPanel(1.5, Unit.EM); p.add(new HTML("this"), "[this]"); p.add(new HTML("that"), "[that]"); p.add(new HTML("the other"), "[the other]"); // Attach the LayoutPanel to the RootLayoutPanel. The latter will listen for // resize events on the window to ensure that its children are informed of // possible size changes. RootLayoutPanel rp = RootLayoutPanel.get(); rp.add(p); } }
A TabLayoutPanel element in a UiBinder
template must have a barHeight
attribute with a double
value, and may have a barUnit
attribute with a
Style.Unit
value.
barUnit
defaults to PX.
The children of a TabLayoutPanel element are laid out in <g:tab>
elements. Each tab can have one widget child and one of two types of header
elements. A <g:header> element can hold html, or a <g:customHeader>
element can hold a widget. (Note that the tags of the header elements are
not capitalized. This is meant to signal that the head is not a runtime
object, and so cannot have a ui:field
attribute.)
For example:
<g:TabLayoutPanel barUnit='PX' barHeight='3'> <g:tab> <g:header size='7'><b>HTML</b> header</g:header> <g:Label>able</g:Label> </g:tab> <g:tab> <g:customHeader size='7'> <g:Label>Custom header</g:Label> </g:customHeader> <g:Label>baker</g:Label> </g:tab> </g:TabLayoutPanel>
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject |
---|
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled |
Field Summary |
---|
Fields inherited from class com.google.gwt.user.client.ui.UIObject |
---|
DEBUG_ID_PREFIX |
Constructor Summary | |
---|---|
TabLayoutPanel(double barHeight,
Style.Unit barUnit)
Creates an empty tab panel. |
Method Summary | |
---|---|
void |
add(Widget w)
Adds a child widget. |
void |
add(Widget child,
java.lang.String text)
Adds a widget to the panel. |
void |
add(Widget child,
java.lang.String text,
boolean asHtml)
Adds a widget to the panel. |
void |
add(Widget child,
Widget tab)
Adds a widget to the panel. |
HandlerRegistration |
addBeforeSelectionHandler(BeforeSelectionHandler<java.lang.Integer> handler)
Adds a BeforeSelectionEvent handler. |
HandlerRegistration |
addSelectionHandler(SelectionHandler<java.lang.Integer> handler)
Adds a SelectionEvent handler. |
void |
clear()
Removes all child widgets. |
int |
getSelectedIndex()
Gets the index of the currently-selected tab. |
Widget |
getTabWidget(int index)
Gets the widget in the tab at the given index. |
Widget |
getTabWidget(Widget child)
Gets the widget in the tab associated with the given child widget. |
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 |
insert(Widget child,
int beforeIndex)
Inserts a widget into the panel. |
void |
insert(Widget child,
java.lang.String text,
boolean asHtml,
int beforeIndex)
Inserts a widget into the panel. |
void |
insert(Widget child,
java.lang.String text,
int beforeIndex)
Inserts a widget into the panel. |
void |
insert(Widget child,
Widget tab,
int beforeIndex)
Inserts a widget into the panel. |
java.util.Iterator<Widget> |
iterator()
Gets an iterator for the contained widgets. |
boolean |
remove(int index)
Removes the widget at the specified index. |
boolean |
remove(Widget w)
Removes a child widget. |
void |
selectTab(int index)
Programmatically selects the specified tab. |
void |
selectTab(Widget child)
Programmatically selects the specified tab. |
void |
setTabHTML(int index,
java.lang.String html)
Sets a tab's HTML contents. |
void |
setTabText(int index,
java.lang.String text)
Sets a tab's text contents. |
Methods inherited from class com.google.gwt.user.client.ui.ResizeComposite |
---|
initWidget, onResize |
Methods inherited from class com.google.gwt.user.client.ui.Composite |
---|
getWidget, isAttached, onAttach, onBrowserEvent, onDetach, setWidget |
Methods inherited from class com.google.gwt.user.client.ui.Widget |
---|
addDomHandler, addHandler, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents |
Methods inherited from class com.google.gwt.user.client.ui.UIObject |
---|
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.google.gwt.event.shared.HasHandlers |
---|
fireEvent |
Constructor Detail |
---|
public TabLayoutPanel(double barHeight, Style.Unit barUnit)
barHeight
- the size of the tab barbarUnit
- the unit in which the tab bar size is specifiedMethod Detail |
---|
public void add(Widget w)
HasWidgets
add
in interface HasWidgets
w
- the widget to be addedpublic void add(Widget child, java.lang.String text)
child
- the widget to be addedtext
- the text to be shown on its tabpublic void add(Widget child, java.lang.String text, boolean asHtml)
child
- the widget to be addedtext
- the text to be shown on its tabasHtml
- true
to treat the specified text as HTMLpublic void add(Widget child, Widget tab)
child
- the widget to be addedtab
- the widget to be placed in the associated tabpublic HandlerRegistration addBeforeSelectionHandler(BeforeSelectionHandler<java.lang.Integer> handler)
HasBeforeSelectionHandlers
BeforeSelectionEvent
handler.
addBeforeSelectionHandler
in interface HasBeforeSelectionHandlers<java.lang.Integer>
handler
- the handler
public HandlerRegistration addSelectionHandler(SelectionHandler<java.lang.Integer> handler)
HasSelectionHandlers
SelectionEvent
handler.
addSelectionHandler
in interface HasSelectionHandlers<java.lang.Integer>
handler
- the handler
public void clear()
HasWidgets
clear
in interface HasWidgets
public int getSelectedIndex()
-1
if none is selected.public Widget getTabWidget(int index)
index
- the index of the tab to be retrieved
public Widget getTabWidget(Widget child)
child
- the child whose tab is to be retrieved
public Widget getWidget(int index)
IndexedPanel
getWidget
in interface IndexedPanel
index
- the child widget's index
public int getWidgetCount()
IndexedPanel
getWidgetCount
in interface IndexedPanel
public int getWidgetIndex(Widget child)
IndexedPanel
getWidgetIndex
in interface IndexedPanel
child
- the widget to be found
-1
if it is not a child of
this panelpublic void insert(Widget child, int beforeIndex)
child
- the widget to be addedbeforeIndex
- the index before which it will be insertedpublic void insert(Widget child, java.lang.String text, boolean asHtml, int beforeIndex)
child
- the widget to be addedtext
- the text to be shown on its tabasHtml
- true
to treat the specified text as HTMLbeforeIndex
- the index before which it will be insertedpublic void insert(Widget child, java.lang.String text, int beforeIndex)
child
- the widget to be addedtext
- the text to be shown on its tabbeforeIndex
- the index before which it will be insertedpublic void insert(Widget child, Widget tab, int beforeIndex)
child
- the widget to be addedtab
- the widget to be placed in the associated tabbeforeIndex
- the index before which it will be insertedpublic java.util.Iterator<Widget> iterator()
HasWidgets
Iterator.remove()
.
iterator
in interface HasWidgets
iterator
in interface java.lang.Iterable<Widget>
public boolean remove(int index)
IndexedPanel
remove
in interface IndexedPanel
index
- the index of the widget to be removed
false
if the widget is not presentpublic boolean remove(Widget w)
HasWidgets
remove
in interface HasWidgets
w
- the widget to be removed
true
if the widget was presentpublic void selectTab(int index)
index
- the index of the tab to be selectedpublic void selectTab(Widget child)
child
- the child whose tab is to be selectedpublic void setTabHTML(int index, java.lang.String html)
setTabText(int, String)
whenever possible.
index
- the index of the tab whose HTML is to be sethtml
- the tab's new HTML contentspublic void setTabText(int index, java.lang.String text)
index
- the index of the tab whose text is to be settext
- the object's new text
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |