Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How can SilkTest click a column header on a JFCTable ?

How can SilkTest click a column header on a JFCTable ?

Although SilkTest does have a built in ClickCol() method this does not always seem to work. There is an alternative, using some of the Native methods of the JDK.

  1. You must expose the JTableHeader control. This can be done by adding the following to your JavaEX.ini under the " [ClassList]" section ;

    javax.swing.table.JTableHeader=true
    

  2. You must then add the following winclass to your declarations ;

    [-] winclass JTableHeader : Control
        [ ] tag "[javax.swing.table.JTableHeader]"
        [ ] 
        [ ] obj RECT getHeaderRect (int i1)
        [ ]
    

    This will expose the getHeaderRect () method within the JTableHeader Control.

  3. Next you will need to change the customwin declaration for the JTableHeader object so that it reads something along the lines of ;

    [-] JTableHeader TheTable2
        [-] msw multitag "[javax.swing.table.JTableHeader]The Table"
            [ ] "[javax.swing.table.JTableHeader]$javax.swing.table.JTableHeader"
    

  4. When this is done you can implement the following function that takes the number of the column header you want to click as a parameter. This could be modified to accept the heading if you wished ;

    [-] ClickHeader(int i )
        [ ] 
        [ ] // Get The width of a Column Header
        [ ] RECT rTable = xTable.TheTable2.getHeaderRect(1)
        [ ] // Get the total number of Columns in the table
        [ ] int iColCount = xTable.TheTable1.GetColumnCount()
        [ ] 
        [ ] // Move to the appropriate point by multiplying the number of columns across
        [ ] // you wish to move by the width and then subtracting half the width of a column.
        [ ] xTable.TheTable2.MoveMouse((rTable.xSize*i)-(rTable.xSize/2),rTable.ySize/2)
        [ ] xTable.TheTable2.Click()
        [ ]
    

Old KB# 22223

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:29
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.