Setting Properties on the Table and on Table Components

You can set properties of the table and of its components to change the appearance of the table. The following table lists common properties that you might set on the table itself.

Property

Description

StartColumn

The first column to display in the table

StartRow

The first row to display in the table

ColumnHeaderVisible

Whether the column header is displayed

RowHeaderVisible

Whether the row header is displayed

ColumnVisible

Whether a particular column appears in the table

RowVisible

Whether a particular row appears in the table

VGridVisible

Whether the vertical gridlines appear in the table

HGridVisible

Whether the horizontal gridlines appear in the table

CellEditingAllowed

Whether users can edit cells in the table

Formatting numbers in tables

The properties for formatting numbers in a table component are in the ViewFormat class. To specify number formatting for the entire table, call the setViewFormat method of the table. You can use rules to specify more granular formatting, such as number formatting for a particular measure.

Properties for table components

Each component has properties of its own. To see the properties for each component, look at the javadoc for each component class.

The most important property for a table component is the ViewStyle property. A ViewStyle object specifies the background color, font color and characteristics, and borders of the cells in a table component.

Setting properties on the ViewStyle a table component affects everything that it contains, such as the grid lines, the cells, and so on. To set properties for individual cells, use rules.

Example: Setting the font color for a header

The following example shows how to set the color of the text in the RowHeader, by setting a property on the ViewStyle object.


table.getRowHeader().getViewStyle().setForeground(Color.red);

Example: Setting the background color of the Databody

The following line of code sets the background color of the Databody to blue.


table.getDatabody().getViewStyle().setBackground(Color.blue);