From: Timothy W. <tw...@us...> - 2004-05-28 11:32:02
|
Because no JTextArea exists in the hierarchy that has been created since the start of the test. Maybe because the component you're looking for doesn't actually derive from JTextArea? pull up an instance under the costello and use the hierarchy browser to examine the component in question. On May 28, 2004, at 4:43 AM, Nirmalya Ghosh wrote: > Hi, > > I get a ComponentNotFoundException thrown with message "No Component > found > with matcher 'Class matcher (javax.swing.JTextArea)'"! > > Any clues as to why this might be happening? > > Thanks & Regards, > nirmalya > ------ > My code looks like : > > final SimpleGUI gui = new SimpleGUI(); //this extends from JPanel > Frame frame = showFrame(gui); > > Component txtArea = null; > try > { txtArea = getFinder().find(new ClassMatcher(JTextArea.class)); } > catch (ComponentNotFoundException e) > { fail("When getting class, "+e.getLocalizedMessage()); } > catch (MultipleComponentsFoundException e) > { fail("When getting class, "+e.getLocalizedMessage()); } > JTextComponentTester tester = new JTextComponentTester(); > > tester.actionEnterText(txtArea,"Bla bla"); > > //Getting the "jTxtAreaData" > JTextArea jTxtAreaData = null; > try > { jTxtAreaData = (JTextArea) getFinder().find(gui, new Matcher() > { public boolean matches(Component c) > { return c.getClass().equals(JLabel.class) > && c.getParent() == gui && c.getName().equals("jTxtAreaData"); > } > }); > } > catch (ComponentNotFoundException e1) > { fail("When getting component, "+e1.getLocalizedMessage()); } > catch (MultipleComponentsFoundException e1) > { fail("When getting component, "+e1.getLocalizedMessage()); } > > > assertEquals("Wrong contents from jTxtAreaData.getText()", > "I expect 'Bla bla'", jTxtAreaData.getText()); > |