Scroll FlexTable : FlexTable « 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.JDK 6
25.JNDI LDAP
26.JPA
27.JSP
28.JSTL
29.Language Basics
30.Network Protocol
31.PDF RTF
32.Reflection
33.Regular Expressions
34.Scripting
35.Security
36.Servlets
37.Spring
38.Swing Components
39.Swing JFC
40.SWT JFace Eclipse
41.Threads
42.Tiny Application
43.Velocity
44.Web Services SOA
45.XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Java » GWT » FlexTableScreenshots 
Scroll FlexTable
 

package com.java2s.gwt.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.*;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTMLTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

public class GWTClient implements EntryPoint{
  private static final int HeaderRowIndex = 0;
  private static final Object[][] rowData = {
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
    "A""D""I""J"},
    "B""E",  "H""K"},
    "C""F""G""L"},
  };
  
  private FlexTable flexTable = new FlexTable();

  public void onModuleLoad() {
    flexTable.insertRow(HeaderRowIndex);
    flexTable.getRowFormatter().addStyleName(HeaderRowIndex,"FlexTable-Header");
    
    addColumn("Column1");
    addColumn("Column12");
    addColumn("Column13");
    addColumn("Column14");
    
    for (int row = 0; row < rowData.length; row++) {
      addRow(rowData[row]);        
    }

    applyDataRowStyles();
    
    flexTable.setCellSpacing(0);
    flexTable.addStyleName("FlexTable");  
    
    ScrollPanel scrollPanel = new ScrollPanel();
    flexTable.setWidth("100%");
    scrollPanel.add(flexTable);
    scrollPanel.setSize("300""200");    
    
    
    RootPanel.get().add(scrollPanel);
  }

  private void addColumn(Object columnHeading) {
    Widget widget = createCellWidget(columnHeading);
    int cell = flexTable.getCellCount(HeaderRowIndex);
    
    widget.setWidth("100%");
    widget.addStyleName("FlexTable-ColumnLabel");
    
    flexTable.setWidget(HeaderRowIndex, cell, widget);
    
    flexTable.getCellFormatter().addStyleName(
        HeaderRowIndex, cell,"FlexTable-ColumnLabelCell");
  }
  
  private Widget createCellWidget(Object cellObject) {
    Widget widget = null;

    if (cellObject instanceof Widget)
      widget = (WidgetcellObject;
    else
      widget = new Label(cellObject.toString());

    return widget;
  }
  int rowIndex = 1;
  private void addRow(Object[] cellObjects) {
    
    for (int cell = 0; cell < cellObjects.length; cell++) {
      Widget widget = createCellWidget(cellObjects[cell]);
      flexTable.setWidget(rowIndex, cell, widget);
      flexTable.getCellFormatter().addStyleName(rowIndex,cell,"FlexTable-Cell");
    }
    rowIndex++;
  }
  
  private void applyDataRowStyles() {
    HTMLTable.RowFormatter rf = flexTable.getRowFormatter();
    
    for (int row = 1; row < flexTable.getRowCount(); ++row) {
      if ((row % 2!= 0) {
        rf.addStyleName(row, "FlexTable-OddRow");
      }
      else {
        rf.addStyleName(row, "FlexTable-EvenRow");
      }
    }
  }
}


           
         
  
GWT-flexTableScroll.zip( 3 k)
Related examples in the same category
1.Use FlexTable
2.FlexTable with row style
3.Table Single Row Click Event
4.Table on Browser Event
5.Table Mouse Over Event
6.extends FlexTable implements TableListener
7.FlexTable with components
8.Using FlexTable to layout buttons (Ext GWT)Using FlexTable to layout buttons (Ext GWT)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.