Topic
  • 10 replies
  • Latest Post - ‏2013-10-18T07:54:08Z by Shrilacxmi
SystemAdmin
SystemAdmin
16727 Posts

Pinned topic How to get column width in a table

‏2011-03-31T13:04:06Z |
Could somebody please tell me how to get the width of a column in a Java table? Thanks in advance.
Updated on 2011-04-29T06:07:31Z at 2011-04-29T06:07:31Z by Sathish804
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: How to get column width in a table

    ‏2011-03-31T13:05:49Z  
    I forgot to say that I'm using RFT 8.1.1.3.
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: How to get column width in a table

    ‏2011-04-05T11:33:55Z  
    I forgot to say that I'm using RFT 8.1.1.3.
    I tried with the Classics Java application but no, I could not get width of a column. Columns are not defined as distinct test objects.
  • Sathish804
    Sathish804
    1305 Posts

    Re: How to get column width in a table

    ‏2011-04-05T11:44:43Z  
    Hi,

    try like this to get the Width and Height of a table cell.

    int row =0;
    int col =0;
     
    java.awt.Rectangle rec = table.getChildren()[row].getChildren()[col].getProperty(".bounds");
     
    int width = rec.width;
    


    Hope this helps you!!!
    Updated on 2014-03-25T13:27:15Z at 2014-03-25T13:27:15Z by iron-man
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: How to get column width in a table

    ‏2011-04-25T18:16:42Z  
    Hi,

    try like this to get the Width and Height of a table cell.

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">int row =0; int col =0; java.awt.Rectangle rec = table.getChildren()[row].getChildren()[col].getProperty(".bounds"); int width = rec.width; </pre>

    Hope this helps you!!!
    This looked promising but unfortunately it could not find .bounds property.
  • Sathish804
    Sathish804
    1305 Posts

    Re: How to get column width in a table

    ‏2011-04-26T05:45:50Z  
    Hi,

    try like this to get the Width and Height of a table cell.

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">int row =0; int col =0; java.awt.Rectangle rec = table.getChildren()[row].getChildren()[col].getProperty(".bounds"); int width = rec.width; </pre>

    Hope this helps you!!!
    Hi,

    If we not able to find the .bounds property of an object then we can use the getClippedScreenRectangle() method of GuiTestObject class which returns the Java rectangle with the objects height and width.

    Try like this.

    nt row =0;
    int col =0;
     
    java.awt.Rectangle rec = new GuiTestObject(table.getChildren()[row].getChildren()[col]).getClippedScreenRectangle();
     
    int width = rec.width;
    


    Hope this helps you!!
    Updated on 2014-03-25T13:26:20Z at 2014-03-25T13:26:20Z by iron-man
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: How to get column width in a table

    ‏2011-04-26T19:41:04Z  
    Hi,

    If we not able to find the .bounds property of an object then we can use the getClippedScreenRectangle() method of GuiTestObject class which returns the Java rectangle with the objects height and width.

    Try like this.

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">nt row =0; int col =0; java.awt.Rectangle rec = new GuiTestObject(table.getChildren()[row].getChildren()[col]).getClippedScreenRectangle(); int width = rec.width; </pre>

    Hope this helps you!!
    I tried your suggestion and the following but they all returned 0

    rec.getWidth()
    rec.getSize()
    rec.heigth
    rec.getHeight()
  • Sathish804
    Sathish804
    1305 Posts

    Re: How to get column width in a table

    ‏2011-04-27T05:24:42Z  
    I tried your suggestion and the following but they all returned 0

    rec.getWidth()
    rec.getSize()
    rec.heigth
    rec.getHeight()
    Can you post your code with Column and Row indexes and also attach the screen shot of table.
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: How to get column width in a table

    ‏2011-04-28T16:40:56Z  
    Can you post your code with Column and Row indexes and also attach the screen shot of table.
    I'm not sure if the screen shot helps. But it's attached. Here's my code:

    int row =0;
    for (int col=0; col<6; ++col) {
    java.awt.Rectangle rec = new GuiTestObject(sysListView32table().getChildren()row.getChildren()col).getClippedScreenRectangle();
    System.out.println(rec.width);
    System.out.println(rec.getWidth());
    System.out.println(rec.height);
    System.out.println(rec.getHeight());
    System.out.println(rec.x);
    System.out.println(rec.y);
    System.out.println(rec.getSize());
    }
  • Sathish804
    Sathish804
    1305 Posts

    Re: How to get column width in a table

    ‏2011-04-29T06:07:31Z  
    I'm not sure if the screen shot helps. But it's attached. Here's my code:

    int row =0;
    for (int col=0; col<6; ++col) {
    java.awt.Rectangle rec = new GuiTestObject(sysListView32table().getChildren()row.getChildren()col).getClippedScreenRectangle();
    System.out.println(rec.width);
    System.out.println(rec.getWidth());
    System.out.println(rec.height);
    System.out.println(rec.getHeight());
    System.out.println(rec.x);
    System.out.println(rec.y);
    System.out.println(rec.getSize());
    }
    Hi,

    The table object is looking like a Window's object, the code snippet i have suggested pretty much works with the Html Table object. For windows table object you have to do some trail and error methods on table object to get the cell object, then you can use getClippedScreenRectangle() method on that object. Directly you can not use getChildren method on the windows table to get the cell object.
  • Shrilacxmi
    Shrilacxmi
    2 Posts

    Re: How to get column width in a table

    ‏2013-10-18T07:54:08Z  
    Hi,

    The table object is looking like a Window's object, the code snippet i have suggested pretty much works with the Html Table object. For windows table object you have to do some trail and error methods on table object to get the cell object, then you can use getClippedScreenRectangle() method on that object. Directly you can not use getChildren method on the windows table to get the cell object.

    hi Sathish,

     

    I am using ITCL framework for my RFT project.

    My problem is that, although the getRowContents() for the particular row (row=1)is having values ,but getCellLink(1, 2) is returning NULL for "Offering Short Name" column .

    while debugging i also found that TestObject[] cell = columns[col].getChildren(); is returning 0 of  getCellObject(int row, int col, String sClassID) method.

    Please suggest.

    A quick response is much appreciated.

    Thanks in Advance.