Class TabBar

java.lang.Object
All Implemented Interfaces:
HasAttachHandlers, HasBeforeSelectionHandlers<Integer>, HasSelectionHandlers<Integer>, HasHandlers, EventListener, ClickListener, HasVisibility, IsRenderable, IsWidget, KeyboardListener, SourcesTabEvents, EventListener
Direct Known Subclasses:
DecoratedTabBar

A horizontal bar of folder-style tabs, most commonly used as part of a TabPanel.

CSS Style Rules

  • .gwt-TabBar { the tab bar itself }
  • .gwt-TabBar .gwt-TabBarFirst { the left edge of the bar }
  • .gwt-TabBar .gwt-TabBarFirst-wrapper { table cell around the left edge }
  • .gwt-TabBar .gwt-TabBarRest { the right edge of the bar }
  • .gwt-TabBar .gwt-TabBarRest-wrapper { table cell around the right edge }
  • .gwt-TabBar .gwt-TabBarItem { unselected tabs }
  • .gwt-TabBar .gwt-TabBarItem-disabled { disabled tabs }
  • .gwt-TabBar .gwt-TabBarItem-wrapper { table cell around tab }
  • .gwt-TabBar .gwt-TabBarItem-wrapper-disabled { table cell around disabled tab }
  • .gwt-TabBar .gwt-TabBarItem-selected { additional style for selected }
  • Example

    public class TabBarExample implements EntryPoint {
    
      public void onModuleLoad() {
        // Create a tab bar with three items.
        TabBar bar = new TabBar();
        bar.addTab("foo");
        bar.addTab("bar");
        bar.addTab("baz");
    
        // Hook up a tab listener to do something when the user selects a tab.
        bar.addSelectionHandler(new SelectionHandler<Integer>() {
          public void onSelection(SelectionEvent<Integer> event) {
            // Let the user know what they just did.
            Window.alert("You clicked tab " + event.getSelectedItem());
          }
        });
    
        // Just for fun, let's disallow selection of 'bar'.
        bar.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
          public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
            if (event.getItem().intValue() == 1) {
              event.cancel();
            }
          }
        });
    
        // Add it to the root panel.
        RootPanel.get().add(bar);
      }
    }