Skip to end of metadata
Go to start of metadata

By default, Swing displays values in instances of JComboBoxe, JList, JTable and JTree. Values are usually displayed using instances of JLabel. Developers can also define their own custom drawing options for those components by providing custom "cell renderers."

The following image shows a JTable using a JComboBox and a JCheckBox as custom renderers for columns 1 and 2 respectively:

FEST-Swing provides support for reading and verifying values (and selected values) from any GUI component that displays something meaningful to the users. FEST-Swing does not obtain those values from the model. Instead, it reads the values as they are displayed on the GUI, as if an actual user were reading them. To do so, FEST-Swing uses custom cell readers (in the package org.fest.swing.cell.)

The following chart shows the fixtures that support custom cell renderers (click on any cell to see Javadoc):

The following code listing show how to verify the values in our sample JTable using the BasicJTableCellReader that comes by default in a JTableFixture:

If your GUI has custom cell renderers that FEST-Swing does not support by default, you can supply your own cell reader. You just need to implement the cell reader interface (see the table above) or extend any of the default implementations.

The following code listing shows how to provide a cell reader for a JTable that uses a JRadioButton as cell renderer:

To use your custom cell reader, you just need to pass an instance of the cell reader to the appropriate fixture through the method cellReader:

Labels
  1. Sep 06, 2010

    In your sample for custom table cell reader, I can not find  "super.cellRendererComponent(table, row, column);".
    I try to find it in all parent classes, but nothing get.
    Where I should get it?

    Thank you!(smile)