JClass
What are some ways that I can alter the appearance of cells in a JCTable?
There are various ways of achieving this. Here are three:
1. Change the default TableCellInfoModel of the table. You can see how this
can be done in the /demos/table/stocks/StockTable.java example that is included
in the installation of JClass. In this example, a separate class is create
which extends JCTableCellInfo. JCTableCellInfo class implements TableCellInfoModel,
and is passed to CellRenderer objects to supply information about the type of
cell being displayed. The default TableCellInfoModel of the table would then
be changed as follows:
table.getCellAreaHandler().setTableCellInfo(new MyJCTableCellInfo());
2. Create a custom renderer. This can be done by either subclassing one of the
renderer classes provided with JClass or by building your own renderer class
from scratch. You can see various ways this can be done throughout the demos
and examples provided with JClass. You may also refer to the JCTable programmer's
guide located off the documentation page on the support web site.
You may also refer to the knowledge base article below for further information
on how to do this (includes sample code).
"Changing the appearance of a cell based on data using a custom cell renderer"
3. Create a JCCellStyle object for specific cells. This may or may not be done
in concert with option #2. When you create a JCCellStyle object, you have
the option to apply a renderer to the cell style. As follows:
cellStyle.setCellRenderer(new MyColorRenderer());
Having said that, you do not have to explicitely set a renderer to a cell style.
You can manipulate the properties of the JCCellStyle object in order to alter
the appearance of the cells. You can see an example of how this can be done in
the following knowledge base article (includes sample codee).
"Changing the appearance of cells based on data using JCCellStyle"
© 2021 Quest Software Inc. ALL RIGHTS RESERVED. Feedback Terms of Use Privacy