Quantcast
Channel:
Viewing all articles
Browse latest Browse all 43798

Wiki Page: How can a JFCTable column heading be clicked in order to arrange the data in according to the header?

$
0
0
  Although there is no inbuilt method to manipulate the data in a JFCTable Column the following steps should allow you to work around the issue. The first step would be to expose the JScrollPane and the JTableHeader classes. These by default are ignored by SilkTest but adding them into the corresponding Javaex.ini file should expose these classes to SilkTest. You need to add these under the [ClassList] section in the aforementioned ini file. It should look something like; [ClassList] javax.swing.JScrollPane=true javax.swing.table.JTableHeader=true Next you need to add the following winclass into your declaration [-] winclass JavaTableHeaderCustomClass : AnyWin [ ] tag "[javax.swing.table.JTableHeader]" [ ] obj RECT getHeaderRect (int a1) This will allow us to use the "built in" Java method getHeaderRect () which is required when it comes to returning the dimensions of the Column Header. You can now go ahead and record a declaration for your Table which should look something like; [-] window JavaDialogBox JFCApplication [ ] tag "JFC Application" [-] CustomWin JavaxSwingJScrollPane [ ] msw tag "[javax.swing.JScrollPane]$javax.swing.JScrollPane" [-] JavaJFCTable JavaxSwingJTable [ ] tag "$javax.swing.JTable" [-] JavaTableHeaderCustomClass JavaxSwingTableJTableHeader [ ] tag "$javax.swing.table.JTableHeader" The next part of the solution we need to implement is the actual locating and clicking of the correct header. The following code will cycle through all the headings until the specified "header" is located. It will return the index of the correct column header. In this example we will search for a column header "Header A". [ ] string columnName = "Header A" [ ] // get the total number of table columns [ ] int totalColumns = JFCApplication.JavaxSwingJScrollPane.JavaxSwingJTable.getColumnCount () [ ] int indexOfSearchName [ ] int i [ ] // loop through the names of each column until we find the one we are looking for [-] for (i=0; i When we have located the correct column header we can use this index to find the dimensions of the header and click the centre. [ ] // get the RECT of the table header within the scrollpane [ ] RECT myRect = JFCApplication.JavaxSwingJScrollPane.JavaxSwingTableJTableHeader.getHeaderRect (indexOfSearchName) [ ] int x, y [ ] [ ] // find the middle point of this RECT [ ] x = myRect.xPos + (myRect.xSize / 2) [ ] y = myRect.yPos + (myRect.ySize / 2) [ ] [ ] // now click in the RECT of the scrollpane [ ] JFCApplication.JavaxSwingJScrollPane.Click (1, x, y) Old KB# 22070

Viewing all articles
Browse latest Browse all 43798