gxwheels152
4 years agoOccasional Contributor
Java Swing table - trouble setting a cell value
Our Application Under Test works extensively with Java Swing tables.
We have been able to click on cells and also extract values from table cells for checkpoint purposes.
But, we are having trouble Setting or Typing into a cell value. Here's what we've tried:
- Recording a Keyword test and Playing it back (it records actual cells and fields within cells as objects and tries to update them). RESULT: no errors, but the cells are not updated
- Using the wValue [Set] on a designated Table and trying to Set the Text for a specific Cell. RESULT: no errors, but the cells are not updated
- Using the wValue [Set] on a designated CellRenderer and trying to Set the Text for a specific Cell. RESULT: received a "The parameter is incorrect" error, which makes sense as the CellRenderer doesn't offer up the wValue option when adding it in from scratch
- Using a script to access a cell within the CellRenderer and trying to Set the Text via the setText() function of the cell. RESULT: no errors and the setText() appears to be available, but also no update to the cells
I followed the principles outlined in the solution to this question about getting Cell Values using the CellRenderer and then checked if the setText() function is available, which it is. I then send in the desired value to the setText() function, but to no avail.
Any help is much appreciated as our Application uses these tables extensively.
def setjTableCellValue(table, rowIndex, columnName, newValue):
Log.Message("GLOBAL: You've are planning to update Cell Value to " + str(newValue) + " for Row: " + str(rowIndex) + " & Column: " + columnName )
columnIndex = getjTableColumnIndex(table,columnName)
tableObjectValue = table.getValueAt(rowIndex, columnIndex)
Log.Message("GLOBAL: You've requested to updated the Cell Value for Row: " + str(rowIndex) + " & Column: " + columnName + " [" + str(columnIndex) + "]")
renderer = table.getCellRenderer(rowIndex, columnIndex).getTableCellRendererComponent(table, tableObjectValue, True, True, rowIndex, columnIndex)
Log.Message("GLOBAL: got the Table Renderer")
if (aqObject.IsSupported(renderer, "setText")) :
Log.Message("In the SetText Section")
renderer.setText(newValue)