Row and Column Headers Begin | Previous | Next
Row Header | Column Header | Column Header Value | Column Header Properties | Row Header Properties | Row Header Spanning

Row Header
The RowHeader can be shown or hidden. The TableHeader above the RowHeader can also be shown or hidden. Properties can be set on cells in the RowHeader just as you would in grid. This example shows the RowHeader and adds labels to each row by turning on the AutoRowLabel. For added flair, it also sets the text style to a 3D look.
grid.setRowHeaderVisible( true );
grid.setRowHeaderAutoLabel( DsGrid.AUTO_LABEL_START_WITH_0 );
grid.getRowHeader().getProperties().setTextStyle( DsGrid.RAISED );
grid.getRowHeader().setColumnHeaderVisible( false );
Column Header
The ColumnHeader can be shown or hidden. The example shows how to hide the ColumnHeader.
grid.setColumnHeaderVisible( false );
Column Header Value
The displayable text in the column header can be set to any object. The text displayed is the string return from the toString method called on the value that is stored for the column. You can also set it by using the setColumnName method on the grid.
grid.getColumnHeader().getCellAt( 1 ).setValue( "one" );
Column Header Properties
As with any cell the properties for cells in the column header can be set. The column header also has some default properties which will set the default value for every cell in the header. The following example will set the default FontBold property for the header then override it and set the color for the cell in column 1.
grid.getColumnHeader().getProperties().setFontBold( true );
grid.getColumnHeader().getCellAt( 1 ).setForeground( Color.red );
grid.getColumnHeader().getCellAt( 1 ).setFontBold( false );
Row Header Properties
As with any cell the properties for cells in the row header can be set. The row header also has some default properties which will set the default value for every cell in the header. The following example will set the default foreground color to blue for the header then override the color for the cell in row 1.
grid.getRowHeader().getProperties().setForeground( Color.blue );
grid.getRowHeader().getCellAt( 1, 0 ).setForeground( Color.red );
Row Header Spanning
A cell can span over the area of the screen occupied by other cells in the Row Header. These other cells will be hidden but will retain their original value and properties. The cell that has spanned over other cells will become the combined size of the range of cells it is spanning. This example creates a span which starts with cell 1,1 and spans 2 columns and 2 rows.
grid.setRowHeaderAutoLabel( DsGrid.AUTO_LABEL_START_WITH_A );
grid.getRowHeader().setColumnCount( 2 );
grid.setRowHeaderAutoLabel( DsGrid.AUTO_LABEL_START_WITH_0 );
grid.getRowHeader().spanCells( 0, 0, 2, 1 );
Copyright 2003 Diamond Edge, Inc. All rights reserved.