All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.util.html.HTMLTable

java.lang.Object
   |
   +----com.ibm.as400.util.html.HTMLTable

public class HTMLTable
extends Object
implements HTMLTagElement, HTMLConstants, Serializable
The HTMLTable class represents an HTML table tag.

This example creates an HTMLTable object and sets its attributes.

  HTMLTable table = new HTMLTable();
  table.setAlignment(HTMLTable.CENTER);
  table.setBorder(1);
  table.setCellSpacing(2);
  table.setCellPadding(2);
  // Add the rows to the table (Assume that the HTMLTableRow objects are already created).
  table.addRow(row1);
  table.addRow(row2);
  table.addRow(row3);
  System.out.println(table.getTag());
  

Here is the output of the table tag:

  <table border="1" align="center" cellspacing="2" cellpadding="2">
  <tr>
  <td>row1data1</td>
  <td>row1data2</td>
  </tr>
  <tr>
  <td>row2data1</td>
  <td>row2data2</td>
  </tr>
  <tr>
  <td>row3data1</td>
  <td>row3data2</td>
  </tr>
  </table>
  

HTMLTable objects generate the following events:

See Also:
HTMLTableRow, HTMLTableCell, HTMLTableHeader, HTMLTableCaption

Constructor Index

 o HTMLTable()
Constructs a default HTMLTable object.
 o HTMLTable(HTMLTableRow[])
Constructs an HTMLTable object with the specified rows.

Method Index

 o addColumn(HTMLTableCell[])
Adds a column to the end of the table.
 o addColumnHeader(HTMLTableHeader)
Adds a column header to the end of the table header.
 o addColumnHeader(String)
Adds a column header to the end of the table header.
 o addPropertyChangeListener(PropertyChangeListener)
Adds a PropertyChangeListener.
 o addRow(HTMLTableRow)
Adds a row to the end of the table.
 o addRowListener(ElementListener)
Adds an ElementListener for the rows.
 o addVetoableChangeListener(VetoableChangeListener)
Adds the VetoableChangeListener.
 o getAlignment()
Returns the table horizontal alignment.
 o getBorderWidth()
Returns the border width.
 o getCaption()
Returns the table caption.
 o getCellPadding()
Returns the global table cell padding.
 o getCellSpacing()
Returns the global table cell spacing.
 o getColumn(int)
Returns a column in the table as an array of HTMLTableCell objects.
 o getColumnHeader(int)
Returns the table header tag for the specified columnIndex.
 o getHeader()
Returns the table column header tags.
 o getHeaderTag()
Returns the HTML tag for the table column headers.
 o getRow(int)
Returns the HTMLTableRow object for the specified rowIndex.
 o getRowCount()
Returns the number of rows in the table.
 o getTag()
Returns the HTML table tag.
 o getWidth()
Returns the table width in pixels or percent.
 o isHeaderInUse()
Indicates if the table column header should be used.
 o isWidthInPercent()
Indicates if the table width is in percent or pixels.
 o removeAllRows()
Removes all the rows from the table.
 o removeColumn(int)
Removes a column from the table at the specified columnIndex.
 o removeColumnHeader(HTMLTableHeader)
Removes a column header from the table header.
 o removeColumnHeader(int)
Removes the column header at the specified columnIndex.
 o removePropertyChangeListener(PropertyChangeListener)
Removes the PropertyChangeListener from the internal list.
 o removeRow(HTMLTableRow)
Removes the row from the table.
 o removeRow(int)
Removes the row at the specified rowIndex.
 o removeRowListener(ElementListener)
Removes this row ElementListener from the internal list.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes the VetoableChangeListener from the internal list.
 o setAlignment(String)
Sets the table horizontal alignment.
 o setBorderWidth(int)
Sets the border width in pixels.
 o setCaption(HTMLTableCaption)
Sets the table caption.
 o setCaption(String)
Sets the table caption.
 o setCellPadding(int)
Sets the global table cell padding.
 o setCellSpacing(int)
Sets the global table cell spacing.
 o setColumn(HTMLTableCell[], int)
Sets a column in the table at the specified columnIndex.
 o setColumnHeader(HTMLTableHeader, int)
Sets the table column header tag at the specified columnIndex.
 o setColumnHeader(String, int)
Sets the table column header tag.
 o setHeader(HTMLTableHeader[])
Sets the table column headers.
 o setHeader(String[])
Sets the table column headers.
 o setHeaderInUse(boolean)
Sets if table column headers should be used.
 o setRow(HTMLTableRow, int)
Sets the table row at the specified rowIndex.
 o setWidth(int)
Sets the table width.
 o setWidth(int, boolean)
Sets the table width in percent or pixels.
 o setWidthInPercent(boolean)
Sets the table width unit in percent or pixels.
 o toString()
Returns the HTML table tag.

Constructors

 o HTMLTable
 public HTMLTable()
Constructs a default HTMLTable object.

 o HTMLTable
 public HTMLTable(HTMLTableRow rows[])
Constructs an HTMLTable object with the specified rows.

Parameters:
rows - An array of HTMLTableRow objects.

Methods

 o addColumn
 public void addColumn(HTMLTableCell column[])
Adds a column to the end of the table.

Parameters:
column - An array of HTMLTableCell objects containing the data.
 o addColumnHeader
 public void addColumnHeader(String header)
Adds a column header to the end of the table header.

Parameters:
header - The column header.
 o addColumnHeader
 public void addColumnHeader(HTMLTableHeader header)
Adds a column header to the end of the table header.

Parameters:
header - The column header.
 o addRow
 public void addRow(HTMLTableRow row)
Adds a row to the end of the table.

Parameters:
row - An HTMLTableRow object containing the row data.
 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener. The specified PropertyChangeListener's propertyChange method is called each time the value of any bound property is changed.

Parameters:
listener - The PropertyChangeListener.
See Also:
removePropertyChangeListener
 o addRowListener
 public void addRowListener(ElementListener listener)
Adds an ElementListener for the rows. The ElementListener object is added to an internal list of RowListeners; it can be removed with removeRowListener.

Parameters:
listener - The ElementListener.
See Also:
removeRowListener
 o addVetoableChangeListener
 public void addVetoableChangeListener(VetoableChangeListener listener)
Adds the VetoableChangeListener. The specified VetoableChangeListener's vetoableChange method is called each time the value of any constrained property is changed.

Parameters:
listener - The VetoableChangeListener.
See Also:
removeVetoableChangeListener
 o getAlignment
 public String getAlignment()
Returns the table horizontal alignment.

Returns:
The table alignment.
 o getBorderWidth
 public int getBorderWidth()
Returns the border width. A value of zero indicates no border.

Returns:
The border width.
 o getCaption
 public HTMLTableCaption getCaption()
Returns the table caption.

Returns:
An HTMLTableCaption object containing the table caption.
 o getCellPadding
 public int getCellPadding()
Returns the global table cell padding. The cell padding is the spacing between data in a table cell and the border of the cell.

Returns:
The cell padding.
 o getCellSpacing
 public int getCellSpacing()
Returns the global table cell spacing. The cell spacing is the spacing between the cells.

Returns:
The cell spacing.
 o getColumn
 public HTMLTableCell[] getColumn(int columnIndex)
Returns a column in the table as an array of HTMLTableCell objects.

Parameters:
columnIndex - The index of the table column (0-based).
Returns:
An array of HTMLTableCell objects.
 o getColumnHeader
 public HTMLTableHeader getColumnHeader(int columnIndex)
Returns the table header tag for the specified columnIndex.

Parameters:
columnIndex - The index of the column header (0-based).
Returns:
The table header tag.
 o getHeader
 public HTMLTableHeader[] getHeader()
Returns the table column header tags.

Returns:
The header tags or null if the header is not set.
 o getHeaderTag
 public String getHeaderTag()
Returns the HTML tag for the table column headers.

Returns:
The HTML table header tag or an empty String if the header is not set.
 o getRowCount
 public int getRowCount()
Returns the number of rows in the table.

Returns:
The number of rows.
 o getRow
 public HTMLTableRow getRow(int rowIndex)
Returns the HTMLTableRow object for the specified rowIndex.

Parameters:
rowIndex - The index of the table row (0-based).
Returns:
The table row object.
 o getTag
 public String getTag()
Returns the HTML table tag.

Returns:
The tag.
 o getWidth
 public int getWidth()
Returns the table width in pixels or percent.

Returns:
The table width.
See Also:
isWidthInPercent
 o isHeaderInUse
 public boolean isHeaderInUse()
Indicates if the table column header should be used.

Returns:
true if column header should be used; false otherwise.
 o isWidthInPercent
 public boolean isWidthInPercent()
Indicates if the table width is in percent or pixels.

Returns:
true if percent, false if pixels.
See Also:
getWidth
 o removeAllRows
 public void removeAllRows()
Removes all the rows from the table.

 o removeColumn
 public void removeColumn(int columnIndex)
Removes a column from the table at the specified columnIndex. If the column header exists it is also removed.

Parameters:
columnIndex - The index of the column to be removed (0-based).
 o removeColumnHeader
 public void removeColumnHeader(int columnIndex)
Removes the column header at the specified columnIndex.

Parameters:
columnIndex - The index of the column header to be removed (0-based).
 o removeColumnHeader
 public void removeColumnHeader(HTMLTableHeader header)
Removes a column header from the table header.

Parameters:
header - The column header.
 o removeRow
 public void removeRow(HTMLTableRow row)
Removes the row from the table.

Parameters:
row - An HTMLTableRow object containing the row data.
 o removeRow
 public void removeRow(int rowIndex)
Removes the row at the specified rowIndex.

Parameters:
rowIndex - The index of the row to be removed (0-based).
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener listener)
Removes the PropertyChangeListener from the internal list. If the PropertyChangeListener is not on the list, nothing is done.

Parameters:
listener - The PropertyChangeListener.
See Also:
addPropertyChangeListener
 o removeRowListener
 public void removeRowListener(ElementListener listener)
Removes this row ElementListener from the internal list. If the ElementListener is not on the list, nothing is done.

Parameters:
listener - The ElementListener.
See Also:
addRowListener
 o removeVetoableChangeListener
 public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes the VetoableChangeListener from the internal list. If the VetoableChangeListener is not on the list, nothing is done.

Parameters:
listener - The VetoableChangeListener.
See Also:
addVetoableChangeListener
 o setAlignment
 public void setAlignment(String alignment) throws PropertyVetoException
Sets the table horizontal alignment. The default value is LEFT.

Parameters:
alignment - The table alignment. One of the following constants defined in HTMLConstants: LEFT, CENTER, or RIGHT.
Throws: PropertyVetoException
If the change is vetoed.
See Also:
HTMLConstants
 o setBorderWidth
 public void setBorderWidth(int borderWidth) throws PropertyVetoException
Sets the border width in pixels. A value of zero indicates no border. The default value is zero.

Parameters:
borderWidth - The border width.
Throws: PropertyVetoException
If the change is vetoed.
 o setCaption
 public void setCaption(String caption) throws PropertyVetoException
Sets the table caption.

Parameters:
caption - The table caption.
Throws: PropertyVetoException
If the change is vetoed.
 o setCaption
 public void setCaption(HTMLTableCaption caption) throws PropertyVetoException
Sets the table caption.

Parameters:
caption - An HTMLTableCaption object containing the table caption.
Throws: PropertyVetoException
If the change is vetoed.
 o setCellPadding
 public void setCellPadding(int cellPadding) throws PropertyVetoException
Sets the global table cell padding. The cell padding is the spacing between data in a table cell and the border of the cell. The default value is zero (browser default used).

Parameters:
cellPadding - The cell padding.
Throws: PropertyVetoException
If the change is vetoed.
 o setCellSpacing
 public void setCellSpacing(int cellSpacing) throws PropertyVetoException
Sets the global table cell spacing. The cell spacing is the spacing between the cells. The default value is zero (browser default used).

Parameters:
cellSpacing - The cell spacing.
Throws: PropertyVetoException
If the change is vetoed.
 o setColumn
 public void setColumn(HTMLTableCell column[],
                       int columnIndex)
Sets a column in the table at the specified columnIndex.

Parameters:
column - An array of HTMLTableCell objects containing the column data.
columnIndex - The index of the column (0-based).
 o setColumnHeader
 public void setColumnHeader(String header,
                             int columnIndex) throws PropertyVetoException
Sets the table column header tag.

Parameters:
header - The table column header.
columnIndex - The index of the column to be changed (0-based).
Throws: PropertyVetoException
If the change is vetoed.
 o setColumnHeader
 public void setColumnHeader(HTMLTableHeader header,
                             int columnIndex) throws PropertyVetoException
Sets the table column header tag at the specified columnIndex.

Parameters:
header - The table column header.
columnIndex - The index of the column to be changed (0-based).
Throws: PropertyVetoException
If the change is vetoed.
 o setHeader
 public void setHeader(HTMLTableHeader header[]) throws PropertyVetoException
Sets the table column headers.

Parameters:
header - The column headers.
Throws: PropertyVetoException
If the change is vetoed.
See Also:
setHeaderInUse
 o setHeader
 public void setHeader(String header[]) throws PropertyVetoException
Sets the table column headers.

Parameters:
header - The column headers.
Throws: PropertyVetoException
If the change is vetoed.
 o setHeaderInUse
 public void setHeaderInUse(boolean headerInUse) throws PropertyVetoException
Sets if table column headers should be used. The default value is true.

Parameters:
headerInUse - true if the column headers should be used; false otherwise.
Throws: PropertyVetoException
If the change is vetoed.
 o setRow
 public void setRow(HTMLTableRow row,
                    int rowIndex)
Sets the table row at the specified rowIndex.

Parameters:
row - An HTMLTableRow object with the row data.
rowIndex - The index of the row (0-based).
 o setWidth
 public void setWidth(int width) throws PropertyVetoException
Sets the table width. The default width unit is pixels.

Parameters:
width - The table width.
Throws: PropertyVetoException
If the change is vetoed.
See Also:
setWidthInPercent
 o setWidth
 public void setWidth(int width,
                      boolean widthInPercent) throws PropertyVetoException
Sets the table width in percent or pixels.

Parameters:
width - The table width.
widthInPercent - true if width is specified as a percent; false if width is specified in pixels.
Throws: PropertyVetoException
If the change is vetoed.
 o setWidthInPercent
 public void setWidthInPercent(boolean widthInPercent) throws PropertyVetoException
Sets the table width unit in percent or pixels. The default is false.

Parameters:
widthInPercent - true if width is specified as a percent; false if width is specified in pixels.
Throws: PropertyVetoException
If the change is vetoed.
See Also:
setWidth
 o toString
 public String toString()
Returns the HTML table tag.

Returns:
The tag.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index