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:
- ElementEvent - The events fired are:
- elementAdded
- elementChanged
- elementRemoved
- PropertyChangeEvent
- VetoableChangeEvent
- See Also:
- HTMLTableRow, HTMLTableCell, HTMLTableHeader, HTMLTableCaption
-
HTMLTable()
- Constructs a default HTMLTable object.
-
HTMLTable(HTMLTableRow[])
- Constructs an HTMLTable object with the specified rows.
-
addColumn(HTMLTableCell[])
- Adds a column to the end of the table.
-
addColumnHeader(HTMLTableHeader)
- Adds a column header to the end of the table header.
-
addColumnHeader(String)
- Adds a column header to the end of the table header.
-
addPropertyChangeListener(PropertyChangeListener)
- Adds a PropertyChangeListener.
-
addRow(HTMLTableRow)
- Adds a row to the end of the table.
-
addRowListener(ElementListener)
- Adds an ElementListener for the rows.
-
addVetoableChangeListener(VetoableChangeListener)
- Adds the VetoableChangeListener.
-
getAlignment()
- Returns the table horizontal alignment.
-
getBorderWidth()
- Returns the border width.
-
getCaption()
- Returns the table caption.
-
getCellPadding()
- Returns the global table cell padding.
-
getCellSpacing()
- Returns the global table cell spacing.
-
getColumn(int)
- Returns a column in the table as an array of HTMLTableCell objects.
-
getColumnHeader(int)
- Returns the table header tag for the specified columnIndex.
-
getHeader()
- Returns the table column header tags.
-
getHeaderTag()
- Returns the HTML tag for the table column headers.
-
getRow(int)
- Returns the HTMLTableRow object for the specified rowIndex.
-
getRowCount()
- Returns the number of rows in the table.
-
getTag()
- Returns the HTML table tag.
-
getWidth()
- Returns the table width in pixels or percent.
-
isHeaderInUse()
- Indicates if the table column header should be used.
-
isWidthInPercent()
- Indicates if the table width is in percent or pixels.
-
removeAllRows()
- Removes all the rows from the table.
-
removeColumn(int)
- Removes a column from the table at the specified columnIndex.
-
removeColumnHeader(HTMLTableHeader)
- Removes a column header from the table header.
-
removeColumnHeader(int)
- Removes the column header at the specified columnIndex.
-
removePropertyChangeListener(PropertyChangeListener)
- Removes the PropertyChangeListener from the internal list.
-
removeRow(HTMLTableRow)
- Removes the row from the table.
-
removeRow(int)
- Removes the row at the specified rowIndex.
-
removeRowListener(ElementListener)
- Removes this row ElementListener from the internal list.
-
removeVetoableChangeListener(VetoableChangeListener)
- Removes the VetoableChangeListener from the internal list.
-
setAlignment(String)
- Sets the table horizontal alignment.
-
setBorderWidth(int)
- Sets the border width in pixels.
-
setCaption(HTMLTableCaption)
- Sets the table caption.
-
setCaption(String)
- Sets the table caption.
-
setCellPadding(int)
- Sets the global table cell padding.
-
setCellSpacing(int)
- Sets the global table cell spacing.
-
setColumn(HTMLTableCell[], int)
- Sets a column in the table at the specified columnIndex.
-
setColumnHeader(HTMLTableHeader, int)
- Sets the table column header tag at the specified columnIndex.
-
setColumnHeader(String, int)
- Sets the table column header tag.
-
setHeader(HTMLTableHeader[])
- Sets the table column headers.
-
setHeader(String[])
- Sets the table column headers.
-
setHeaderInUse(boolean)
- Sets if table column headers should be used.
-
setRow(HTMLTableRow, int)
- Sets the table row at the specified rowIndex.
-
setWidth(int)
- Sets the table width.
-
setWidth(int, boolean)
- Sets the table width in percent or pixels.
-
setWidthInPercent(boolean)
- Sets the table width unit in percent or pixels.
-
toString()
- Returns the HTML table tag.
HTMLTable
public HTMLTable()
- Constructs a default HTMLTable object.
HTMLTable
public HTMLTable(HTMLTableRow rows[])
- Constructs an HTMLTable object with the specified rows.
- Parameters:
- rows - An array of HTMLTableRow objects.
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.
addColumnHeader
public void addColumnHeader(String header)
- Adds a column header to the end of the table header.
- Parameters:
- header - The column header.
addColumnHeader
public void addColumnHeader(HTMLTableHeader header)
- Adds a column header to the end of the table header.
- Parameters:
- header - The column header.
addRow
public void addRow(HTMLTableRow row)
- Adds a row to the end of the table.
- Parameters:
- row - An HTMLTableRow object containing the row data.
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
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
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
getAlignment
public String getAlignment()
- Returns the table horizontal alignment.
- Returns:
- The table alignment.
getBorderWidth
public int getBorderWidth()
- Returns the border width. A value of zero indicates no border.
- Returns:
- The border width.
getCaption
public HTMLTableCaption getCaption()
- Returns the table caption.
- Returns:
- An HTMLTableCaption object containing the table caption.
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.
getCellSpacing
public int getCellSpacing()
- Returns the global table cell spacing.
The cell spacing is the spacing between the cells.
- Returns:
- The cell spacing.
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.
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.
getHeader
public HTMLTableHeader[] getHeader()
- Returns the table column header tags.
- Returns:
- The header tags or null if the header is not set.
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.
getRowCount
public int getRowCount()
- Returns the number of rows in the table.
- Returns:
- The number of rows.
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.
getTag
public String getTag()
- Returns the HTML table tag.
- Returns:
- The tag.
getWidth
public int getWidth()
- Returns the table width in pixels or percent.
- Returns:
- The table width.
- See Also:
- isWidthInPercent
isHeaderInUse
public boolean isHeaderInUse()
- Indicates if the table column header should be used.
- Returns:
- true if column header should be used; false otherwise.
isWidthInPercent
public boolean isWidthInPercent()
- Indicates if the table width is in percent or pixels.
- Returns:
- true if percent, false if pixels.
- See Also:
- getWidth
removeAllRows
public void removeAllRows()
- Removes all the rows from the table.
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).
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).
removeColumnHeader
public void removeColumnHeader(HTMLTableHeader header)
- Removes a column header from the table header.
- Parameters:
- header - The column header.
removeRow
public void removeRow(HTMLTableRow row)
- Removes the row from the table.
- Parameters:
- row - An HTMLTableRow object containing the row data.
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).
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
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
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
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
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.
setCaption
public void setCaption(String caption) throws PropertyVetoException
- Sets the table caption.
- Parameters:
- caption - The table caption.
- Throws: PropertyVetoException
- If the change is vetoed.
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.
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.
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.
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).
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.
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.
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
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.
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.
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).
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
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.
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
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