Forum Discussion

zaheer_akhter's avatar
zaheer_akhter
Occasional Contributor
10 years ago

Comparing image in Jtable

I have Jtable with rows and columns, The Image icon is Stop (red colour) and Go green colour.

I want to click the row only when the particular cell has green icon.

I am using Testcomplete/javascript 



Application is desktop using java.



Anyone has done this before?

2 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Zaheer,

     


    The pseudocode of the comparison function can look like this:




    // get the cell with the image by its row and column


    var cell = ...


     


    // save the currently displayed icon


    var curImage = cell.Picture() 


     


    // get the image for the comparison. It can be stored in Stores


    var desiredImage = Regions.GetPicture("StoredImageName") 


     


    // compare if the current and the desired images are the same


    if (curImage.Find(desiredImage)


    {


      Log.Message("The cell contains the desired icon")


    }




     


    I suggest that you read the "Finding an Image Within Another Image" article for details.


     

  • zaheer_akhter's avatar
    zaheer_akhter
    Occasional Contributor
    Hi Tanya, Thanks for reply.



    I tried to get the cell with the image value for column/row using following code




    var cell = table.getCell(row, column) / var cell =table.getvalueAt(row, column)



    I dont get any value back hence the next statment



    var curImage = cell.Picture()



     fails



    Do you have any idea how do i get cell witht the image by its row and column.