Controlling the visual appearance

Top  Previous  Next

 

Just as in JTableHeader, the cells are rendered by a TableCellRenderer object. The following JTableRowHeader's methods are used for creating, getting and setting the cell renderer:

 

protected TableCellRenderer createDefaultRowRenderer();

public TableCellRenderer getDefaultRowRenderer();

public void setDefaultRowRenderer(TableCellRenderer defaultRenderer);

 

By default, JTableRowHeader uses a DefaultRowHeaderRenderer to render its cells. The cells in a DefaultRowHeaderRenderer are rendered as a JButton, which text is set to the string value of the cell.

 

The value of each cell is determined by the method:

 

protected Object getColumnHeaderValue(int rowIndex);

 

By default, this method returns the current row number as a string.