Class ComponentSearcher

java.lang.Object
org.netbeans.jemmy.ComponentSearcher
All Implemented Interfaces:
Outputable

public class ComponentSearcher extends Object implements Outputable
Contains methods to search for components below a a given java.awt.Container in the display containment hierarchy. Uses a ComponentChooser interface implementation to find a component.
Author:
Alexandre Iline (alexandre.iline@sun.com)
See Also:
  • Constructor Details

    • ComponentSearcher

      public ComponentSearcher(Container c)
      Contructor. The search is constrained so that only components that lie below the given container in the containment hierarchy are considered.
      Parameters:
      c - Container to find components in.
  • Method Details

    • getTrueChooser

      public static ComponentChooser getTrueChooser(String description)
      Creates ComponentChooser implementation whose checkComponent(Component) method returns true for any component.
      Parameters:
      description - Component description.
      Returns:
      ComponentChooser instance.
    • setOutput

      public void setOutput(TestOut output)
      Defines print output streams or writers.
      Specified by:
      setOutput in interface Outputable
      Parameters:
      output - ?out? Identify the streams or writers used for print output.
      See Also:
    • getOutput

      public TestOut getOutput()
      Returns print output streams or writers.
      Specified by:
      getOutput in interface Outputable
      Returns:
      an object that contains references to objects for printing to output and err streams.
      See Also:
    • findComponent

      public Component findComponent(ComponentChooser chooser, int index)
      Searches for a component. The search for the component proceeds recursively in the component hierarchy rooted in this ComponentChooser's container.
      Parameters:
      chooser - ComponentChooser instance, defining and applying the search criteria.
      index - Ordinal component index. Indices start at 0.
      Returns:
      the index'th component from among those components for which the chooser's checkComponent(Component) method returns true. A null reference is returned if there are fewer than index-1 components meeting the search criteria exist in the component hierarchy rooted in this ComponentChooser's container.
    • findComponent

      public Component findComponent(ComponentChooser chooser)
      Searches for a component. The search for the component proceeds recursively in the component hierarchy rooted in this ComponentChooser's container.
      Parameters:
      chooser - ComponentChooser instance, defining and applying the search criteria.
      Returns:
      the first component for which the chooser's checkComponent(Component) method returns true. A null reference is returned if no component meeting the search criteria exist in the component hierarchy rooted in this ComponentChooser's container.