Creating Tab Panel using GWT

This example describes the Basics for building the Tab Panel using GWT.

Creating Tab Panel using GWT


This example describes the Basics for building the Tab Panel using GWT. The steps involved in Building the Tab Panel are described below:-

final Label label = new Label("Click the Tab below to view content")
Here we are declaring label. Label is a widget that contains text.

TabPanel tp = new TabPanel()
Here we are creating object of TabPanel class. TabPanel  is a panel that represents a tabbed set of pages, each of which contains another widget.

HTML index = new HTML("Tab you have selected is Index.")
Creating an object of class HTML named index. HTML is a widget that can contain arbitrary HTML.

tp.add(index, "Index ")
This is a method of Tab Panel class for adding a widget to the tab panel.

By this method we are adding label to the root panel. Root panel is a panel to which all other widgets must  be added. it is not created directly.

package org.yournamehere.client;


public class TabPanelEx {

  public void onModuleLoad() {
  final Label label = new 
Label("Click the Tab below to view content");
  final Label label1 = new 
Label("   ");
  TabPanel tp = new TabPanel();
  HTML index1 = new HTML("");
  HTML index = new HTML("Tab you have selected is Index.");
  tp.add(index, "Index ");

  HTML homeText = new HTML("Tab you have selected is Home.");
  tp.add(homeText, " Home  ");

  HTML moreInfo = new
HTML("Tab you have selected is MoreInfo.");
  tp.add(moreInfo, "  MoreInfo  ");



<?xml version="1.0" encoding="UTF-8"?>
  <inherits name=""/>
  <entry-point class="org.yournamehere.client.TabPanelEx"/>

Output of the program

Download sourcecode


Share on Google+Share on Google+

Creating Tab Panel using GWT

Posted on: October 8, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Creating Tab Panel using GWT   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
June 14, 2012

GWT has changed the laandcspe. It turned millions of server-side java developers into browser-based developers. I hesitate to call them JavaScript developers since one really doesn't touch any JavaScript when using GWT. We wouldn't call Java developer that uses JNI a C programmer.You did hit on the GWTs biggest challenge: HTML/CSS integration. The library basically lets you know that you are on your own when it comes to styling your application. It will be interesting to see how people create HTML/CSS frameworks around the GWT plumbing.