GWT Flextable Example

In this example we will learn about GWT Flextable. A flextable allows user to create cell on demand. It can be jagged (that is, each row can contain a different number of cells) and individual cells can be set to span multiple rows or columns.. Tools and technologies used in this example are Java 1.8, Eclipse Luna 4.4.2, Eclipse GWT Plugin 2.6

1. GWT

GWT is a development toolkit for building and optimizing complex browser-based applications. Its goal is to enable productive development of high-performance web applications without the developer having to be an expert in browser quirks, XMLHttpRequest, and JavaScript. GWT is used by many products at Google, including AdWords, AdSense, Flights, Hotel Finder, Offers, Wallet, Blogger. It’s open source, completely free, and used by thousands of developers around the world.

The FlexTable class extends the HTMLTable.

public class FlexTable extends HTMLTable

Below we show the class hierarchy of the FlexTable class:

Figure 1. Class Hierarchy
Figure 1. Class Hierarchy


2. Important methods

Here we will describe the important methods in the FlexTable class.

  • addCell: Appends a cell to the specified row.
  • getCellCountGets the number of cells on a given row.
  • getFlexCellFormatter: Explicitly gets the FlexTable.FlexCellFormatter. The results of HTMLTable.getCellFormatter() may also be downcast to a FlexTable.FlexCellFormatter.
  • getRowCount: Gets the number of rows.
  • insertCell: Inserts a cell into the FlexTable.
  • insertRow Inserts a row into the FlexTable.

3. Project setup

Below is the screenshot of project setup.

Figure 2. Project Setup
Figure 2. Project Setup


4. GWT Configuration

Below we describe the GWT configuration file where we define the EntryPoint.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.6.0//EN"
<module rename-to='flextableexample'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name=''/> -->
<inherits name=''/>

<!-- Specify the app entry point class. -->
<entry-point class='com.javacodegeeks.client.FlexTableExample'/>

<!-- Specify the paths for translatable code -->
<source path='client'/>
<add-linker name="xsiframe"/>

5. Java class

Below is the GWT FlexTable Example class.

package com.javacodegeeks.client;


* Entry point classes define <code>onModuleLoad()</code>.
public class FlexTableExample implements EntryPoint {
* This is the entry point method.
  public void onModuleLoad() {
    FlexTable t = new FlexTable();
    // setText method is inherited from HTMLTable class.
    t.setText(0, 0, "First element");
    t.setText(0, 1, "Second element");
    t.setText(1, 0, "Third element");
    t.setWidget(1, 1, new Button("Button"));


6. GWT Compile

To compile the application, right click on the project and choose Google=>GWT Compile. See the screenshot below.

Figure 2. GWT Compile
Figure 2. GWT Compile

You will see a popup as below. Click on Compile.

7. Running the application

To run the application right click on the project then select Run As=>Web Application (GWT Classic Dev Mode). Copy the URL ( shown in the ‘Development Mode’ tab. Remove the part after the ‘.html’. So the URL becomes ‘’. Click Enter.

8. Download the source file

This was an example of GWT Flextable

You can download the full source code of this example here : GWT FlexTable Example

Mohammad Meraj Zia

Senior Java Developer
Notify of

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

Inline Feedbacks
View all comments
Back to top button