Hi,
Is there any way to get the javax.swing.JTable cells (content) text width provided cells text font is
Font("Arial", 16).
I am trying get the maximum width Ranorex.Table.Column[].Cell[].Text.
Thanks.
How to get the javax.swing.JTable Cells text width
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to get the javax.swing.JTable Cells text width
Hello,
You could use the 'Length' property of the text to get the number of characters.
If you want to get the maximum text width, you could iterate over all cells and compare the value.
Please take a look at the code snippet below:
Markus (T)
You could use the 'Length' property of the text to get the number of characters.
If you want to get the maximum text width, you could iterate over all cells and compare the value.
Please take a look at the code snippet below:
int maxLength = 0; IList<Cell> cells = Host.Local.Find<Cell>("/form[@title='Java Test']//table[@name='jTable1']/row/cell"); foreach (Cell cell in cells) { Report.Info("Cell: " + cell.Text + " Width: " + cell.Text.Length); if (cell.Text.Length>maxLength) maxLength = cell.Text.Length; } Report.Info("Length: " + maxLength);You could access the font and size of the table by using the following code:
jTable1.Element.GetAttributeValueText("Font.Name") jTable1.Element.GetAttributeValueText("Font.Size")Regards,
Markus (T)