Interface ComponentFinder
- All Known Implementing Classes:
BasicComponentFinder
Component lookup.-
Method Summary
Modifier and TypeMethodDescriptionfind(Container root, ComponentMatcher m) Finds ausing the givenComponentin the hierarchy under the given root.ComponentMatcher<T extends Component>
Tfind(Container root, GenericTypeMatcher<T> m) Finds ausing the givenComponentin the hierarchy under the given root.GenericTypeMatcherFinds ausing the givenComponent.ComponentMatcher<T extends Component>
Tfind(GenericTypeMatcher<T> m) Finds ausing the givenComponent.GenericTypeMatcherfindAll(Container root, ComponentMatcher m) Returns all thes under the given root that match the search criteria specified in the givenComponent.ComponentMatcher<T extends Component>
Collection<T>findAll(Container root, GenericTypeMatcher<T> m) Returns all thes under the given root that match the search criteria specified in the givenComponent.GenericTypeMatcherReturns all thes that match the search criteria specified in the givenComponent.ComponentMatcher<T extends Component>
Collection<T>findAll(GenericTypeMatcher<T> m) Returns all thes that match the search criteria specified in the givenComponent.GenericTypeMatcherfindByLabel(Container root, String label) findByLabel(Container root, String label, boolean showing) <T extends Component>
TfindByLabel(Container root, String label, Class<T> type) <T extends Component>
TfindByLabel(Container root, String label, Class<T> type, boolean showing) findByLabel(String label) findByLabel(String label, boolean showing) <T extends Component>
TfindByLabel(String label, Class<T> type) <T extends Component>
TfindByLabel(String label, Class<T> type, boolean showing) findByName(Container root, String name) Finds aby name, in the hierarchy under the given root.ComponentfindByName(Container root, String name, boolean showing) Finds aby name, in the hierarchy under the given root.Component<T extends Component>
TfindByName(Container root, String name, Class<T> type) Finds aby name and type, in the hierarchy under the given root.Component<T extends Component>
TfindByName(Container root, String name, Class<T> type, boolean showing) Finds aby name and type, in the hierarchy under the given root.ComponentfindByName(String name) Finds aby name.ComponentfindByName(String name, boolean showing) Finds aby name.Component<T extends Component>
TfindByName(String name, Class<T> type) Finds aby name and type.Component<T extends Component>
TfindByName(String name, Class<T> type, boolean showing) Finds aby name and type.Component<T extends Component>
TfindByType(Container root, Class<T> type) Finds aby type in the hierarchy under the given root.Component<T extends Component>
TfindByType(Container root, Class<T> type, boolean showing) Finds aby type in the hierarchy under the given root.Component<T extends Component>
TfindByType(Class<T> type) Finds aby type.Component<T extends Component>
TfindByType(Class<T> type, boolean showing) Finds aby type.ComponentbooleanReturns whether the message in ashould include the current component hierarchy.ComponentLookupExceptionvoidincludeHierarchyIfComponentNotFound(boolean newValue) Updates whether the message in ashould include the current component hierarchy.ComponentLookupExceptionprinter()Returns thein this finder.ComponentPrinter
-
Method Details
-
printer
ComponentPrinter printer()Returns thein this finder.ComponentPrinter- Returns:
- the
ComponentPrinterin this finder.
-
findByType
Finds aby type. If this finder is attached to aComponent, it will use the component lookup scope in theRobotRobot'sto determine whether the component to find should be showing or not. If this finder is not attached to anySettingsRobot, the component to find does not have to be showing.Example:
JTextField textbox = finder.findByType(JTextField.class);
- Type Parameters:
T- the parameterized type of the component to find.- Parameters:
type- the type of the component to find.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByType
Finds aby type. For example:Component- Type Parameters:
T- the parameterized type of the component to find.- Parameters:
type- the type of the component to find.showing- indicates whether the component to find should be visible (or showing) or not.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByType
Finds a
by type in the hierarchy under the given root. If this finder is attached to aComponent, it will use the component lookup scope in theRobotRobot'sto determine whether the component to find should be showing or not. If this finder is not attached to anySettingsRobot, the component to find does not have to be showing.Let's assume we have the following
containing aJFrame:JTextFieldJFrame myFrame = new JFrame(); myFrame.add(new JTextField());
If we want to get a reference to the
in that particularJTextFieldwithout going through the whole AWT component hierarchy, we could simply specify:JFrameJTextField textbox = finder.findByType(myFrame, JTextField.class);
- Type Parameters:
T- the parameterized type of the component to find.- Parameters:
root- the root used as the starting point of the search.type- the type of the component to find.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByType
Finds aby type in the hierarchy under the given root.Component- Type Parameters:
T- the parameterized type of the component to find.- Parameters:
root- the root used as the starting point of the search.showing- indicates whether the component to find should be visible (or showing) or not.type- the type of the component to find.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByLabel
Finds a
by by the text of its associatedComponent. If this finder is attached to aJLabel, it will use the component lookup scope in theRobotRobot'sto determine whether the component to find should be showing or not. If this finder is not attached to anySettingsRobot, the component to find does not have to be showing.Let's assume we have the
with aJTextFieldwith text "Name";JLabelJLabel label = new JLabel("Name"); JTextField textbox = new JTextField(); label.setLabelFor(textBox);To get a reference to this
by the text of its associatedJTextFieldJLabel, we can specify:JTextField textBox = (JTextField) finder.findByLabel("Name");Please note that you need to cast the result of the lookup to the right type. To avoid casting, please use one of following:
- Parameters:
label- the text of theJLabelassociated to the component to find.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByLabel
Finds aby the text of its associatedComponentand type. If this finder is attached to aJLabel, it will use the component lookup scope in theRobotRobot'sto determine whether the component to find should be showing or not. If this finder is not attached to anySettingsRobot, the component to find does not have to be showing.- Type Parameters:
T- the parameterized type of the component to find.- Parameters:
label- the text of theJLabelassociated to the component to find.type- the type of the component to find.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByLabel
- Type Parameters:
T- the parameterized type of the component to find.- Parameters:
label- the text of theJLabelassociated to the component to find.type- the type of the component to find.showing- indicates whether the component to find should be visible (or showing) or not.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByLabel
- Parameters:
label- the text of theJLabelassociated to the component to find.showing- indicates whether the component to find should be visible (or showing) or not.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByLabel
Finds aby the text of its associatedComponent, in the hierarchy under the given root. If this finder is attached to aJLabel, it will use the component lookup scope in theRobotRobot'sto determine whether the component to find should be showing or not. If this finder is not attached to anySettingsRobot, the component to find does not have to be showing.- Parameters:
root- the root used as the starting point of the search.label- the text of theJLabelassociated to the component to find.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByLabel
- Parameters:
root- the root used as the starting point of the search.label- the text of theJLabelassociated to the component to find.showing- indicates whether the component to find should be visible (or showing) or not.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByLabel
Finds aby the text of its associatedComponentand type, in the hierarchy under the given root. If this finder is attached to aJLabel, it will use the component lookup scope in theRobotRobot'sto determine whether the component to find should be showing or not. If this finder is not attached to anySettingsRobot, the component to find does not have to be showing.- Type Parameters:
T- the parameterized type of the component to find.- Parameters:
root- the root used as the starting point of the search.label- the text of theJLabelassociated to the component to find.type- the type of the component to find.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByLabel
Finds aby the text of its associatedComponentand type, in the hierarchy under the given root.JLabel- Type Parameters:
T- the parameterized type of the component to find.- Parameters:
root- the root used as the starting point of the search.label- the text of theJLabelassociated to the component to find.type- the type of the component to find.showing- indicates whether the component to find should be visible (or showing) or not.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByName
Finds a
by name. If this finder is attached to aComponent, it will use the component lookup scope in theRobotRobot'sto determine whether the component to find should be showing or not. If this finder is not attached to anySettingsRobot, the component to find does not have to be showing.Let's assume we have the
with name "myTextBox";JTextFieldJTextField textbox = new JTextField(); textBox.setName("myTextBox");To get a reference to this
by its name, we can specify:JTextFieldJTextField textBox = (JTextField) finder.findByName("myTextBox");Please note that you need to cast the result of the lookup to the right type. To avoid casting, please use one of following:
- Parameters:
name- the name of the component to find.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByName
Finds aby name and type. If this finder is attached to aComponent, it will use the component lookup scope in theRobotRobot'sto determine whether the component to find should be showing or not. If this finder is not attached to anySettingsRobot, the component to find does not have to be showing.- Type Parameters:
T- the parameterized type of the component to find.- Parameters:
name- the name of the component to find.type- the type of the component to find.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByName
Finds aby name and type.Component- Type Parameters:
T- the parameterized type of the component to find.- Parameters:
name- the name of the component to find.type- the type of the component to find.showing- indicates whether the component to find should be visible (or showing) or not.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByName
Finds aby name.Component- Parameters:
name- the name of the component to find.showing- indicates whether the component to find should be visible (or showing) or not.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByName
Finds aby name, in the hierarchy under the given root. If this finder is attached to aComponent, it will use the component lookup scope in theRobotRobot'sto determine whether the component to find should be showing or not. If this finder is not attached to anySettingsRobot, the component to find does not have to be showing.- Parameters:
root- the root used as the starting point of the search.name- the name of the component to find.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByName
Finds aby name, in the hierarchy under the given root.Component- Parameters:
root- the root used as the starting point of the search.name- the name of the component to find.showing- indicates whether the component to find should be visible (or showing) or not.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByName
Finds aby name and type, in the hierarchy under the given root. If this finder is attached to aComponent, it will use the component lookup scope in theRobotRobot'sto determine whether the component to find should be showing or not. If this finder is not attached to anySettingsRobot, the component to find does not have to be showing.- Type Parameters:
T- the parameterized type of the component to find.- Parameters:
root- the root used as the starting point of the search.name- the name of the component to find.type- the type of the component to find.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
findByName
Finds aby name and type, in the hierarchy under the given root.Component- Type Parameters:
T- the parameterized type of the component to find.- Parameters:
root- the root used as the starting point of the search.name- the name of the component to find.type- the type of the component to find.showing- indicates whether the component to find should be visible (or showing) or not.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.- See Also:
-
find
Finds ausing the givenComponent. The given matcher will be evaluated in the event dispatch thread. Implementations ofComponentMatcherComponentMatcherdo not need to be concerned about the event dispatch thread.- Parameters:
m- the matcher to use to find the component of interest.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.
-
find
Finds ausing the givenComponent. The given matcher will be evaluated in the event dispatch thread. Implementations ofGenericTypeMatcherGenericTypeMatcherdo not need to be concerned about the event dispatch thread.- Type Parameters:
T- the type of component the given matcher can handle.- Parameters:
m- the matcher to use to find the component of interest.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.
-
find
Finds ausing the givenComponentin the hierarchy under the given root. The given matcher will be evaluated in the event dispatch thread. Implementations ofGenericTypeMatcherGenericTypeMatcherdo not need to be concerned about the event dispatch thread.- Type Parameters:
T- the type of component the given matcher can handle.- Parameters:
root- the root used as the starting point of the search.m- the matcher to use to find the component.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.
-
find
Finds ausing the givenComponentin the hierarchy under the given root. The given matcher will be evaluated in the event dispatch thread. Implementations ofComponentMatcherComponentMatcherdo not need to be concerned about the event dispatch thread.- Parameters:
root- the root used as the starting point of the search.m- the matcher to use to find the component.- Returns:
- the found component.
- Throws:
ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.
-
findAll
Returns all thes that match the search criteria specified in the givenComponent.ComponentMatcher- Parameters:
m- the matcher to use to find the component.- Returns:
- all the
Components that match the search criteria specified in the givenComponentMatcher; or an empty collection, if there are no matching components.
-
findAll
Returns all thes under the given root that match the search criteria specified in the givenComponent.ComponentMatcher- Parameters:
root- the root used as the starting point of the search.m- the matcher to use to find the component.- Returns:
- all the
Components under the given root that match the search criteria specified in the givenComponentMatcher; or an empty collection, if there are no matching components.
-
findAll
Returns all thes that match the search criteria specified in the givenComponent.GenericTypeMatcher- Type Parameters:
T- the generic type of component that this search supports.- Parameters:
m- the matcher to use to find the component.- Returns:
- all the
Components that match the search criteria specified in the givenGenericTypeMatcher; or an empty collection, if there are no matching components.
-
findAll
Returns all thes under the given root that match the search criteria specified in the givenComponent.GenericTypeMatcher- Type Parameters:
T- the generic type of component that this search supports.- Parameters:
root- the root used as the starting point of the search.m- the matcher to use to find the component.- Returns:
- all the
Components under the given root that match the search criteria specified in the givenGenericTypeMatcher; or an empty collection, if there are no matching components.
-
includeHierarchyIfComponentNotFound
boolean includeHierarchyIfComponentNotFound()Returns whether the message in ashould include the current component hierarchy. The default value isComponentLookupExceptiontrue.- Returns:
trueif the component hierarchy is included as part of theComponentLookupExceptionmessage,falseotherwise.
-
includeHierarchyIfComponentNotFound
void includeHierarchyIfComponentNotFound(boolean newValue) Updates whether the message in ashould include the current component hierarchy. The default value isComponentLookupExceptiontrue.- Parameters:
newValue- the new value to set.
-