Set selected tab (Ext GWT) : Tab « GWT « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JavaFX
25.JDK 6
26.JDK 7
27.JNDI LDAP
28.JPA
29.JSP
30.JSTL
31.Language Basics
32.Network Protocol
33.PDF RTF
34.Reflection
35.Regular Expressions
36.Scripting
37.Security
38.Servlets
39.Spring
40.Swing Components
41.Swing JFC
42.SWT JFace Eclipse
43.Threads
44.Tiny Application
45.Velocity
46.Web Services SOA
47.XML
Java » GWT » Tab 




Set selected tab (Ext GWT)
Set selected tab (Ext GWT)
 

/*
 * Ext GWT - Ext for GWT
 * Copyright(c) 2007-2009, Ext JS, LLC.
 [email protected]
 
 * http://extjs.com/license
 */



package com.google.gwt.sample.hello.client;

import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.button.ToggleButton;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.RootPanel;

public class Hello implements EntryPoint {
  public void onModuleLoad() {
    RootPanel.get().add(new AdvancedTabExample());
  }
}
class AdvancedTabExample extends LayoutContainer {

  private int index = 0;
  private TabPanel advanced;

  @Override
  protected void onRender(Element parent, int pos) {
    super.onRender(parent, pos);
    VerticalPanel vp = new VerticalPanel();
    vp.setSpacing(10);

    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(5);

    Button add = new Button("Add Tab");
    add.addSelectionListener(new SelectionListener<ButtonEvent>() {
      @Override
      public void componentSelected(ButtonEvent ce) {
        addTab();
        advanced.setSelection(advanced.getItem(index - 1));
      }
    });
    hp.add(add);

    ToggleButton toggle = new ToggleButton("Enable Tab Context Menu");
    toggle.addListener(Events.Toggle, new Listener<ButtonEvent>() {
      public void handleEvent(ButtonEvent be) {
        advanced.setCloseContextMenu(((ToggleButtonbe.getButton()).isPressed());
      }
    });
    toggle.toggle(true);
    hp.add(toggle);
    vp.add(hp);

    advanced = new TabPanel();
    advanced.setSize(600250);
    advanced.setMinTabWidth(115);
    advanced.setResizeTabs(true);
    advanced.setAnimScroll(true);
    advanced.setTabScroll(true);
    advanced.setCloseContextMenu(true);

    while (index < 7) {
      addTab();
    }

    advanced.setSelection(advanced.getItem(6));

    vp.add(advanced);
    add(vp);
  }

  private void addTab() {
    TabItem item = new TabItem();
    item.setText("New Tab " + ++index);
    item.setClosable(index != 1);
    item.addText("Tab Body " + index);
    item.addStyleName("pad-text");
    advanced.add(item);
  }

}

   
  














Ext-GWT.zip( 4,297 k)
Related examples in the same category
1.Tab orientation (Smart GWT)Tab orientation (Smart GWT)
2.Set tab alignment (Smart GWT)Set tab alignment (Smart GWT)
3.Add a tab, remove a tab (Smart GWT)Add a tab, remove a tab (Smart GWT)
4.Closable tab (Smart GWT)Closable tab (Smart GWT)
5.Tabs Custom Control Sample (Smart GWT)Tabs Custom Control Sample (Smart GWT)
6.Change Tab title dynamically (Smart GWT)Change Tab title dynamically (Smart GWT)
7.Add controls to Tab page (Smart GWT)Add controls to Tab page (Smart GWT)
8.Set URL view for Tab (Smart GWT)Set URL view for Tab (Smart GWT)
9.Scrollable tab header line (Smart GWT)Scrollable tab header line (Smart GWT)
10.Basic Focus Tabbing Sample (Smart GWT)Basic Focus Tabbing Sample (Smart GWT)
11.Using tab to hold form (Smart GWT)Using tab to hold form (Smart GWT)
12.Click on the resizebar next to the Navigation tree to hide it (Smart GWT)Click on the resizebar next to the Navigation tree to hide it (Smart GWT)
13.Adding text to tab panel (Ext GWT)Adding text to tab panel (Ext GWT)
14.Adding Autoload ajax content to tab panel (Ext GWT)Adding Autoload ajax content to tab panel (Ext GWT)
15.Listen to tab selection event (Ext GWT)Listen to tab selection event (Ext GWT)
16.Adding icon to tab bar (Ext GWT)Adding icon to tab bar (Ext GWT)
17.Diable a tab item (Ext GWT)Diable a tab item (Ext GWT)
18.Using VerticalPanel to hold tab panel (Ext GWT)Using VerticalPanel to hold tab panel (Ext GWT)
19.Adding HTML content to a tab panel (Ext GWT)Adding HTML content to a tab panel (Ext GWT)
20.Adding new tab dynamically (Ext GWT)Adding new tab dynamically (Ext GWT)
21.Closable tab (Ext GWT)Closable tab (Ext GWT)
22.Enable tab context menu (Ext GWT)Enable tab context menu (Ext GWT)
23.Make tab scrollable (Ext GWT)Make tab scrollable (Ext GWT)
24.Tabbed Form (Ext GWT)Tabbed Form (Ext GWT)
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.