From: Sowmya P. <con...@ya...> - 2005-04-28 03:02:15
|
John, Thanks for your suggestion, but I think I might have not been clear in presenting my problem. I am not trying to expand my tree by clicking on it - that is not the GUI under test. I am merely traversing the tree programmatically (a data structure I created that represents the components of the GUI under test in a hierarchical format) until I find the component of the GUI that needs to be clicked (say, button or menu item as required by the test case). Once, I find the component of the GUI, I want to return this object as a Component object to the actionClick method of ComponentTester so that I can simulate user-click on the component of the GUI, say button click. I'm trying to traverse the tree to find my desired component using TreeModel's getChild(Object parent, int index) method which is returning an object (of the type Object). I want to convert this object to a Component type so that actionClick method of ComponentTester might accept it. But, trying to type-cast this object to a Component type is throwing ClassCastException. Have I made myself clear? Thanks, Sowmya. "Crutcher, John" <Joh...@co...> wrote: I had a similar problem, and remember it was a casting problem in Abbot. Instead of trying to fix Abbot, I solved it by using the swing methods thusly: JTreeTable participantsTable = myTable; JTree tree; tree = participantsTable.getTree(); tree.expandRow(cell.row); // (instead of actionClick Can you send the entire stack trace, maybe I can help you more about where the problem occurred, instead of assuming youre having the same problem? -----Original Message----- From: abb...@li... [mailto:abb...@li...] On Behalf Of Sowmya Padmanabhan Sent: Wednesday, April 27, 2005 4:11 PM To: abb...@li... Subject: [abbot-users] Type-casting an object (of type Object) to Component type to pass to actionClick method of ComponentTester Hi All- Im trying to find a particular child in a JTree structure that I created by walking through the contents of AWTHierarchy and then trying to pass this child as a component object to actionClick method of ComponentTester class for clicking on the corresponding component of the GUI under test. To search through the JTree object for particular child, I am using TreeModel class and its getChild method. The problem: Im having trouble casting the object of the type Object returned by the getChild method of TreeModel class into a Component class type of object. I need to have this object as a Component object as I eventually pass this object to actionClick method of ComponentTester class to click on the corresponding object. actionClick method does not accept a parameter that is of the type Object. Here is the snippet of the code: -------------------------------------------------------- ... TreeModel model = tree.getModel(); Object child = model.getChild (parent, index); Component comp = (Component) child; -------------------------------------------------------- I get the following exception: java.lang.ClassCastException What else could I do to make this child object acceptable as a parameter of actionClick method of ComponentTester class since the type-casting is just not working for me? Thanks, in advance, for any suggestions you might have! Sowmya. |