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 |
---|---|
|
The first column to display in the table |
|
The first row to display in the table |
|
Whether the column header is displayed |
|
Whether the row header is displayed |
|
Whether a particular column appears in the table |
|
Whether a particular row appears in the table |
|
Whether the vertical gridlines appear in the table |
|
Whether the horizontal gridlines appear in the table |
|
Whether users can edit cells in the table |
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.
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.
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);
Databody
The following line of code sets the background color of the Databody
to blue.
table.getDatabody().getViewStyle().setBackground(Color.blue);