org.fest.swing.cell
Interface JTableCellWriter

All Known Implementing Classes:
AbstractJTableCellWriter, BasicJTableCellWriter, JTableCheckBoxEditorCellWriter, JTableComboBoxEditorCellWriter, JTableTextComponentEditorCellWriter

@RunsInEDT
public interface JTableCellWriter

Understands how to edit the value of a cell in a JTable.

Author:
Yvonne Wang, Alex Ruiz

Method Summary
 void cancelCellEditing(JTable table, int row, int column)
          Cancels editing the given cell of the JTable.
 Component editorForCell(JTable table, int row, int column)
          Returns the Component used as editor of the given cell.
 void enterValue(JTable table, int row, int column, String value)
          Enters the given value at the given cell of the JTable.
 void startCellEditing(JTable table, int row, int column)
          Starts editing the given cell of the JTable.
 void stopCellEditing(JTable table, int row, int column)
          Stops editing the given cell of the JTable.
 

Method Detail

enterValue

void enterValue(JTable table,
                int row,
                int column,
                String value)
Enters the given value at the given cell of the JTable. To edit a cell using this method, it is not necessary to call startCellEditing(JTable, int, int) or stopCellEditing(JTable, int, int).

Parameters:
table - the target JTable.
row - the row index of the cell.
column - the column index of the cell.
value - the value to enter.
Throws:
IllegalStateException - if the JTable is disabled.
IllegalStateException - if the JTable is not showing on the screen.
IllegalStateException - if the JTable cell is not editable.
IndexOutOfBoundsException - if any of the indices (row and column) is out of bounds.
ActionFailedException - if an editor for the given cell cannot be found or cannot be activated.

startCellEditing

void startCellEditing(JTable table,
                      int row,
                      int column)
Starts editing the given cell of the JTable. This method should be called before manipulating the Component returned by editorForCell(JTable, int, int).

Parameters:
table - the target JTable.
row - the row index of the cell.
column - the column index of the cell.
Throws:
IllegalStateException - if the JTable is disabled.
IllegalStateException - if the JTable is not showing on the screen.
IllegalStateException - if the JTable cell is not editable.
IndexOutOfBoundsException - if any of the indices (row and column) is out of bounds.
ActionFailedException - if an editor for the given cell cannot be found or cannot be activated.
See Also:
editorForCell(JTable, int, int)

stopCellEditing

void stopCellEditing(JTable table,
                     int row,
                     int column)
Stops editing the given cell of the JTable. This method should be called after manipulating the Component returned by editorForCell(JTable, int, int).

Parameters:
table - the target JTable.
row - the row index of the cell.
column - the column index of the cell.
Throws:
IllegalStateException - if the JTable is disabled.
IllegalStateException - if the JTable is not showing on the screen.
IllegalStateException - if the JTable cell is not editable.
IndexOutOfBoundsException - if any of the indices (row and column) is out of bounds.
ActionFailedException - if an editor for the given cell cannot be found or cannot be activated.
See Also:
editorForCell(JTable, int, int)

cancelCellEditing

void cancelCellEditing(JTable table,
                       int row,
                       int column)
Cancels editing the given cell of the JTable. This method should be called after manipulating the Component returned by editorForCell(JTable, int, int).

Parameters:
table - the target JTable.
row - the row index of the cell.
column - the column index of the cell.
Throws:
IllegalStateException - if the JTable is disabled.
IllegalStateException - if the JTable is not showing on the screen.
IllegalStateException - if the JTable cell is not editable.
IndexOutOfBoundsException - if any of the indices (row and column) is out of bounds.
ActionFailedException - if an editor for the given cell cannot be found or cannot be activated.
See Also:
editorForCell(JTable, int, int)

editorForCell

Component editorForCell(JTable table,
                        int row,
                        int column)
Returns the Component used as editor of the given cell. To manipulate the returned Component, startCellEditing(JTable, int, int) should be called first.

Example:

 Component editor = writer.editorForCell(table, 6, 8);
 // assume editor is a JTextField
 JTextComponentFixture editorFixture = new JTextComponentFixture(robot, (JTextField) editor);
 writer.startCellEditing(table, 6, 8);
 editorFixture.enterText("Hello");
 writer.stopCellEditing(table, 6, 8);
 

Parameters:
table - the target JTable.
row - the row index of the cell.
column - the column index of the cell.
Returns:
the Component used as editor of the given cell.
Throws:
IllegalStateException - if the JTable cell is not editable.
IndexOutOfBoundsException - if any of the indices (row and column) is out of bounds.
IllegalStateException - if the JTable cell is not editable.


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.