Custom Cell Editors
Swing provides cell editors for JTables and JTrees. For example, by default JTables support JTextFields, JComboBoxes and JCheckBoxes as cell editors, as the following figure illustrates:

FEST-Swing provides support for editing JTable cells (support for JTree coming soon) as if a user was doing it. To accomplish this, FEST-Swing uses custom cell writers (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):
| Fixture | Cell Writer | Default Implementation | Supported Cell Editor |
JTableFixture | JTableCellWriter | BasicJTableCellWriter | JTextComponent, JComboBox, JCheckBox |
JTreeFixture | Coming soon | N/A | N/A |
If your GUI has custom cell editors that FEST-Swing does not support by default, you can supply your own cell writer. You just need to implement the cell writer interface (see the table above) or extend any of the default implementations.
The following code listing shows how to provide a cell writer for a JTable that uses a JRadioButton as cell editor:
public class MyJTableCellWriter extends BasicJTableCellWriter { @Override public void enterValue(JTable table, int row, int column, String value) { Component c = super.editorForCell(table, row, column); if (c instanceof JRadioButton) { ((JRadioButton)c).setSelected(Boolean.parseBoolean(value)); return; } super.enterValue(table, row, column, value); } }
To use your custom cell reader, you just need to pass an instance of the cell reader to the appropriate fixture through the method cellWriter:
JTableFixture table = dialog.table("data"); table.cellWriter(new MyJTableCellWriter());
