sdsu.html
Class HTMLTable

java.lang.Object
  |
  +--sdsu.html.HTMLTable

public class HTMLTable
extends java.lang.Object
implements HTML

Implements an HTML table. This allows displaying of items in rows and columns. Here is an example of an HTML table with: border size 2, a Caption, centered, width at 70%, the first row and column set as headers.

The Caption
 Row 0 (zero) is declared to be a header
Column 0 is a Cell 1,1Cell 1, 2 Cell 1, 2
headerCell 1,1  


Version:
0.8 6 April 1997
Author:
Roger Whitney (whitney@cs.sdsu.edu)

Constructor Summary
HTMLTable(int numberOfRows, int numberOfColumns)
          Create a new table with given number of rows and columns.
HTMLTable(Table initialTableElements)
          Create a new html table with element given by the sdsu.util.Table
 
Method Summary
 void alignCenter()
          Centers the table in the page.
 void alignLeft()
          Left justifies the table.
 void alignRight()
          Right justifies the table.
 java.lang.String elementAt(int row, int column)
          Returns the string version of the object in table at given row and column.
 void makeColumnAHeader(int column)
          Makes the given column a header for the rows of table.
 void makeRowAHeader(int row)
          Makes the given row a header for the columns of table.
 void setBorderWidth(int pixelWidth)
          Sets the width of the border drawn around table and indivitual cells.
 void setCaption(Formatter caption)
          Sets text caption displayed above the table.
 void setElementAt(HTML data, int row, int column)
          Places string representation of data in table at given row and column
 void setElementAt(java.lang.Object data, int row, int column)
          Places string representation of data in table at given row and column
 void setWidth(int pixelWidth)
          Suggests a width in pixels of the table.
 void setWidthPercent(int percentOfWindowWidth)
          Suggests a width for the table in percent of window width.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HTMLTable

public HTMLTable(int numberOfRows,
                 int numberOfColumns)
Create a new table with given number of rows and columns. All elements are set to the empty string.
Parameters:
numberOfRows - number of rows in the table
numberOfColumns - number of colums in the table

HTMLTable

public HTMLTable(Table initialTableElements)
Create a new html table with element given by the sdsu.util.Table
Parameters:
initialTableElements - table containing the initial elements for the html table
Method Detail

alignCenter

public void alignCenter()
Centers the table in the page. Does not affect the alignment of the items in each table location.

alignRight

public void alignRight()
Right justifies the table. The right edge of the table will start on the right edge of the page. Does not affect the alignment of the items in each table location.

alignLeft

public void alignLeft()
Left justifies the table. The Left edge of the table will start on the left edge of the page. This is the default setting. Does not affect the alignment of the items in each table location.

setBorderWidth

public void setBorderWidth(int pixelWidth)
Sets the width of the border drawn around table and indivitual cells. default setting is border of one pixel. Pixel size of zero gives no border.
Parameters:
pixelWidth - width of border in pixels

setCaption

public void setCaption(Formatter caption)
Sets text caption displayed above the table.
Parameters:
caption - displayed above table

makeRowAHeader

public void makeRowAHeader(int row)
Makes the given row a header for the columns of table. Netscape will center and make bold all items on the given row.
Parameters:
row - index of the row to be the header

makeColumnAHeader

public void makeColumnAHeader(int column)
Makes the given column a header for the rows of table. Netscape will center and make bold all items on the given column.
Parameters:
column - index of the column to be the header

setElementAt

public void setElementAt(HTML data,
                         int row,
                         int column)
                  throws java.lang.ArrayIndexOutOfBoundsException
Places string representation of data in table at given row and column
Parameters:
data - HTML object whose string representation is added to the table
Throws:
java.lang.ArrayIndexOutOfBoundsException - thrown if row or column is not a valid index

setElementAt

public void setElementAt(java.lang.Object data,
                         int row,
                         int column)
                  throws java.lang.ArrayIndexOutOfBoundsException
Places string representation of data in table at given row and column
Parameters:
data - Item whose string representation is added to the table, special characters are escaped for you
Throws:
java.lang.ArrayIndexOutOfBoundsException - thrown if row or column is not a valid index

setWidth

public void setWidth(int pixelWidth)
Suggests a width in pixels of the table. Browser will try to use this width.
Parameters:
pixelWidth - suggested width of the table in pixels.

setWidthPercent

public void setWidthPercent(int percentOfWindowWidth)
Suggests a width for the table in percent of window width. Browser will try to use this width.
Parameters:
percentOfWindowWidth - int between 0 and 100

elementAt

public java.lang.String elementAt(int row,
                                  int column)
                           throws java.lang.ArrayIndexOutOfBoundsException
Returns the string version of the object in table at given row and column.
Throws:
java.lang.ArrayIndexOutOfBoundsException - thrown if row or column is not a valid index

toString

public java.lang.String toString()
Specified by:
toString in interface HTML
Overrides:
toString in class java.lang.Object