Home » Enterprise Java » gwt » TabPanel Example

About Ilias Tsagklis

Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.

TabPanel Example

This is an example of how to create a TabPanel example using the Google Web Toolkit, that is an open source set of tools that allows web developers to create and maintain complex JavaScript front-end applications in Java. A TabPanel is 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 HTML. To create a TabPanel we have performed the following steps:

  • The TabPanelExample class implements the com.google.gwt.core.client.EntryPoint interface to allow the class to act as a module entry point. It overrides its onModuleLoad() method.
  • Create a new Tab Panel. Set some styling to it, such as the size. Add some content and name each Tab of the Tab Panel.
  • Add the TabPanel to the RootPanel, that is the panel to which all other widgets must ultimately be added.

Let’s take a look at the code snippet that follows: 

package com.javacodegeeks.snippets.enterprise;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TabPanel;

public class TabPanelExample implements EntryPoint {

	public void onModuleLoad() {

  // Create new Tab Panel
		TabPanel tabPanel = new TabPanel();

  // Set some styling

  tabPanel.setSize("500px", "250px");

  // Add some content and name each Tab 
		tabPanel.add(new HTML("Tab0 Contents"),"Tab0");
		tabPanel.add(new HTML("Tab1 Contents"),"Tab1");
		tabPanel.add(new HTML("Tab2 Contents"),"Tab2");
		tabPanel.add(new HTML("Tab3 Contents"),"Tab3");

  // Set default Tab view on page load

  // Add Tab Panel to Root Panel

This was an example of how to create a TabPanel example.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....


Receive Java & Developer job alerts in your Area

I have read and agree to the terms & conditions


Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments