com.google.gwt.user.client.ui
Class Grid

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Panel
              extended by com.google.gwt.user.client.ui.HTMLTable
                  extended by com.google.gwt.user.client.ui.Grid
All Implemented Interfaces:
HasClickHandlers, HasHandlers, EventListener, HasWidgets, SourcesTableEvents, java.lang.Iterable<Widget>

public class Grid
extends HTMLTable

A rectangular grid that can contain text, html, or a child Widget within its cells. It must be resized explicitly to the desired number of rows and columns.

Example


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.HTMLTable
HTMLTable.Cell, HTMLTable.CellFormatter, HTMLTable.ColumnFormatter, HTMLTable.RowFormatter
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
Grid()
          Constructor for Grid.
Grid(int rows, int columns)
          Constructs a grid with the requested size.
 
Method Summary
 boolean clearCell(int row, int column)
          Replaces the contents of the specified cell with a single space.
 int getCellCount(int row)
          Return number of columns.
 int getColumnCount()
          Gets the number of columns in this grid.
 int getRowCount()
          Return number of rows.
 int insertRow(int beforeRow)
          Inserts a new row into the table.
 void removeRow(int row)
          Removes the specified row from the table.
 void resize(int rows, int columns)
          Resizes the grid.
 void resizeColumns(int columns)
          Resizes the grid to the specified number of columns.
 void resizeRows(int rows)
          Resizes the grid to the specified number of rows.
 
Methods inherited from class com.google.gwt.user.client.ui.HTMLTable
addClickHandler, addTableListener, clear, clear, getCellForEvent, getCellFormatter, getCellPadding, getCellSpacing, getColumnFormatter, getHTML, getRowFormatter, getText, getWidget, isCellPresent, iterator, remove, removeTableListener, setBorderWidth, setCellPadding, setCellSpacing, setHTML, setText, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Panel
add
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
fireEvent, getLayoutData, getParent, isAttached, onBrowserEvent, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Constructor Detail

Grid

public Grid()
Constructor for Grid.


Grid

public Grid(int rows,
            int columns)
Constructs a grid with the requested size.

Parameters:
rows - the number of rows
columns - the number of columns
Throws:
java.lang.IndexOutOfBoundsException
Method Detail

clearCell

public boolean clearCell(int row,
                         int column)
Replaces the contents of the specified cell with a single space.

Overrides:
clearCell in class HTMLTable
Parameters:
row - the cell's row
column - the cell's column
Returns:
true if a widget was removed
Throws:
java.lang.IndexOutOfBoundsException

getCellCount

public int getCellCount(int row)
Return number of columns. For grid, row argument is ignored as all grids are rectangular.

Specified by:
getCellCount in class HTMLTable
Parameters:
row - the row whose cells are to be counted
Returns:
the number of cells present in the row

getColumnCount

public int getColumnCount()
Gets the number of columns in this grid.

Returns:
the number of columns

getRowCount

public int getRowCount()
Return number of rows.

Specified by:
getRowCount in class HTMLTable
Returns:
the table's row count

insertRow

public int insertRow(int beforeRow)
Inserts a new row into the table. If you want to add multiple rows at once, use resize(int, int) or resizeRows(int) as they are more efficient.

Parameters:
beforeRow - the index before which the new row will be inserted
Returns:
the index of the newly-created row
Throws:
java.lang.IndexOutOfBoundsException

removeRow

public void removeRow(int row)
Description copied from class: HTMLTable
Removes the specified row from the table.

Parameters:
row - the index of the row to be removed

resize

public void resize(int rows,
                   int columns)
Resizes the grid.

Parameters:
rows - the number of rows
columns - the number of columns
Throws:
java.lang.IndexOutOfBoundsException

resizeColumns

public void resizeColumns(int columns)
Resizes the grid to the specified number of columns.

Parameters:
columns - the number of columns
Throws:
java.lang.IndexOutOfBoundsException

resizeRows

public void resizeRows(int rows)
Resizes the grid to the specified number of rows.

Parameters:
rows - the number of rows
Throws:
java.lang.IndexOutOfBoundsException