cancel
Showing results for 
Search instead for 
Did you mean: 

Issue getting table cell renderer component from JTable

SOLVED
Contributor

Issue getting table cell renderer component from JTable

Greetings,

 

I wrote some js to retrieve the rendered value from a cell in my application's JTable, but TestComplete keeps locking up when calling the method: getTableCellRendererComponent()

 

Here is my code:

/*
* Returns the displayed value in the specified JTable cell
* 
* Parameters:
* table - a JTable object
* row - integer index of the row
* column - integer index of the column
*/
function getRenderedValue(table, row, column) {
  let value = null;
  let columnModel = null;
  let columnObj = null;
  let renderer = null;
  let component = null;

  if (0 > row) {
    Log.Error(`Row index must be greater than or equal to 0: ${row}`);
    return null;
  } /* if: the provided row index is less than 0 */

  Log.Message(`Getting rendered value found from cell: (row=${row}, column=${column})`);

  value     = table.getValueAt(row, column);

  columnModel = table.getColumnModel();

  Log.Message(`Getting column object by column index: ${column}`);
  columnObj = columnModel.getColumn(column);

  Log.Message(`Getting renderer for column: ${columnObj}`);
  renderer  = columnObj.getCellRenderer();

  Log.Message(`Get component for renderer: ${renderer}`);

  component  = renderer.getTableCellRendererComponent(table, value, false, false, row, column);

  Log.Message(`Get text for component: ${component}`);

  if (aqObject.IsSupported(component, "getText")) {
    value = component.getText();
  }

  return value;
} /* end function: getRenderedValue(table, row, column) */

The table I am providing to this function is a simple JTable, but it does use a custom TableModel and a custom TableColumnModel. All of the renderers within this table are custom as well. I have tried calling this function for the first cell and row in table which is essentially just a String value and it still fails.

 

I would appreciate anyone's insight as to why the test - and java application - lock up.

 

I eventually have to kill the process for my application in order to have testcomplete finally release its hold on the application.

 

I've attached the logged messages for executuion:

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: Issue getting table cell renderer component from JTable

Hi @BTscott,

Hmmm, I have never seen this error posted to the Community. Could you please refer this question to the Support Team? They will need to reproduce it in their test lab.

 
---------
Tanya Gorbunova
SmartBear Community Manager

 Join SmartBear Connect next April in Boston to meet with software development, API and testing experts from around the world! Get your ticket today!

View solution in original post

2 REPLIES 2
Highlighted
Contributor

Re: Issue getting table cell renderer component from JTable

Please let me know if you need more information. Thank you.

Community Manager

Re: Issue getting table cell renderer component from JTable

Hi @BTscott,

Hmmm, I have never seen this error posted to the Community. Could you please refer this question to the Support Team? They will need to reproduce it in their test lab.

 
---------
Tanya Gorbunova
SmartBear Community Manager

 Join SmartBear Connect next April in Boston to meet with software development, API and testing experts from around the world! Get your ticket today!

View solution in original post