@RunsInEDT public interface ComponentFinder
Component
lookup.Modifier and Type | Method and Description |
---|---|
Component |
find(ComponentMatcher m)
Finds a
using the given . |
Component |
find(Container root,
ComponentMatcher m)
Finds a
using the given in the hierarchy
under the given root. |
<T extends Component> |
find(Container root,
GenericTypeMatcher<T> m)
Finds a
using the given in the hierarchy
under the given root. |
<T extends Component> |
find(GenericTypeMatcher<T> m)
Finds a
using the given . |
Collection<Component> |
findAll(ComponentMatcher m)
Returns all the
s that match the search criteria specified in the given
. |
Collection<Component> |
findAll(Container root,
ComponentMatcher m)
Returns all the
s under the given root that match the search criteria specified in
the given . |
<T extends Component> |
findAll(Container root,
GenericTypeMatcher<T> m)
Returns all the
s under the given root that match the search criteria specified in
the given . |
<T extends Component> |
findAll(GenericTypeMatcher<T> m)
Returns all the
s that match the search criteria specified in the given
. |
Component |
findByLabel(Container root,
String label)
|
Component |
findByLabel(Container root,
String label,
boolean showing)
|
<T extends Component> |
findByLabel(Container root,
String label,
Class<T> type)
|
<T extends Component> |
findByLabel(Container root,
String label,
Class<T> type,
boolean showing)
|
Component |
findByLabel(String label)
|
Component |
findByLabel(String label,
boolean showing)
|
<T extends Component> |
findByLabel(String label,
Class<T> type)
|
<T extends Component> |
findByLabel(String label,
Class<T> type,
boolean showing)
|
Component |
findByName(Container root,
String name)
Finds a
by name, in the hierarchy under the given root. |
Component |
findByName(Container root,
String name,
boolean showing)
Finds a
by name, in the hierarchy under the given root. |
<T extends Component> |
findByName(Container root,
String name,
Class<T> type)
Finds a
by name and type, in the hierarchy under the given root. |
<T extends Component> |
findByName(Container root,
String name,
Class<T> type,
boolean showing)
Finds a
by name and type, in the hierarchy under the given root. |
Component |
findByName(String name)
Finds a
by name. |
Component |
findByName(String name,
boolean showing)
Finds a
by name. |
<T extends Component> |
findByName(String name,
Class<T> type)
Finds a
by name and type. |
<T extends Component> |
findByName(String name,
Class<T> type,
boolean showing)
Finds a
by name and type. |
<T extends Component> |
findByType(Class<T> type)
Finds a
by type. |
<T extends Component> |
findByType(Class<T> type,
boolean showing)
Finds a
by type. |
<T extends Component> |
findByType(Container root,
Class<T> type)
Finds a
by type in the hierarchy under the given root. |
<T extends Component> |
findByType(Container root,
Class<T> type,
boolean showing)
Finds a
by type in the hierarchy under the given root. |
boolean |
includeHierarchyIfComponentNotFound()
Returns whether the message in a
should include the current component
hierarchy. |
void |
includeHierarchyIfComponentNotFound(boolean newValue)
Updates whether the message in a
should include the current component
hierarchy. |
ComponentPrinter |
printer()
Returns the
in this finder. |
ComponentPrinter printer()
ComponentPrinter
in this finder.ComponentPrinter
in this finder.<T extends Component> T findByType(Class<T> type)
Component
by type. If this finder is attached to a Robot
, it will
use the component lookup scope in the Robot
's Settings
to determine whether the
component to find should be showing or not. If this finder is not attached to any Robot
, the
component to find does not have to be showing.
Example:
JTextField textbox = finder.findByType(JTextField.class);
T
- the parameterized type of the component to find.type
- the type of the component to find.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.Robot.settings()
,
Settings.componentLookupScope()
,
ComponentLookupScope
<T extends Component> T findByType(Class<T> type, boolean showing)
Component
by type. For example:T
- the parameterized type 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.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.findByType(Class)
<T extends Component> T findByType(Container root, Class<T> type)
Finds a
by type in the hierarchy under the given root. If this finder is attached to
a Component
, it will use the component lookup scope in the Robot
Robot
's
to determine whether the component to find should be showing or not. If this finder
is not attached to any Settings
Robot
, the component to find does not have to be showing.
Let's assume we have the following
containing a
JFrame
:
JTextField
JFrame myFrame = new JFrame(); myFrame.add(new JTextField());
If we want to get a reference to the
in that particular
JTextField
without going through the whole AWT component hierarchy, we could simply
specify:
JFrame
JTextField textbox = finder.findByType(myFrame, JTextField.class);
T
- the parameterized type of the component to find.root
- the root used as the starting point of the search.type
- the type of the component to find.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.Robot.settings()
,
Settings.componentLookupScope()
,
ComponentLookupScope
<T extends Component> T findByType(Container root, Class<T> type, boolean showing)
Component
by type in the hierarchy under the given root.T
- the parameterized type of the component to find.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.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.findByType(Container, Class)
Component findByLabel(String label)
Finds a
by by the text of its associated Component
. If this finder
is attached to a JLabel
, it will use the component lookup scope in the Robot
Robot
's
to determine whether the component to find should be showing or not. If this finder
is not attached to any Settings
Robot
, the component to find does not have to be showing.
Let's assume we have the
with a JTextField
with text
"Name";
JLabel
JLabel label = new JLabel("Name"); JTextField textbox = new JTextField(); label.setLabelFor(textBox);
To get a reference to this
by the text of its associated
JTextField
JLabel
, 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:
label
- the text of the JLabel
associated to the component to find.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.JLabel.getLabelFor()
,
JLabel.setLabelFor(Component)
,
Robot.settings()
,
Settings.componentLookupScope()
,
ComponentLookupScope
<T extends Component> T findByLabel(String label, Class<T> type)
Component
by the text of its associated JLabel
and type. If this
finder is attached to a Robot
, it will use the component lookup scope in the
Robot
's Settings
to determine whether the component to find should be showing or
not. If this finder is not attached to any Robot
, the component to find does not have to be
showing.T
- the parameterized type of the component to find.label
- the text of the JLabel
associated to the component to find.type
- the type of the component to find.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.findByLabel(String)
,
JLabel.getLabelFor()
,
JLabel.setLabelFor(Component)
,
Robot.settings()
,
Settings.componentLookupScope()
,
ComponentLookupScope
<T extends Component> T findByLabel(String label, Class<T> type, boolean showing)
T
- the parameterized type of the component to find.label
- the text of the JLabel
associated 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.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.findByLabel(String)
,
JLabel.getLabelFor()
,
JLabel.setLabelFor(Component)
Component findByLabel(String label, boolean showing)
label
- the text of the JLabel
associated to the component to find.showing
- indicates whether the component to find should be visible (or showing) or not.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.findByLabel(String)
,
JLabel.getLabelFor()
,
JLabel.setLabelFor(Component)
Component findByLabel(Container root, String label)
Component
by the text of its associated JLabel
, in the hierarchy
under the given root. If this finder is attached to a Robot
, it will use the component lookup
scope in the Robot
's Settings
to determine whether the component to find should
be showing or not. If this finder is not attached to any Robot
, the component to find does
not have to be showing.root
- the root used as the starting point of the search.label
- the text of the JLabel
associated to the component to find.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.findByLabel(String)
,
JLabel.getLabelFor()
,
JLabel.setLabelFor(Component)
,
Robot.settings()
,
Settings.componentLookupScope()
,
ComponentLookupScope
Component findByLabel(Container root, String label, boolean showing)
root
- the root used as the starting point of the search.label
- the text of the JLabel
associated to the component to find.showing
- indicates whether the component to find should be visible (or showing) or not.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.findByLabel(String)
,
JLabel.getLabelFor()
,
JLabel.setLabelFor(Component)
<T extends Component> T findByLabel(Container root, String label, Class<T> type)
Component
by the text of its associated JLabel
and type, in the
hierarchy under the given root. If this finder is attached to a Robot
, it will use the
component lookup scope in the Robot
's Settings
to determine whether the component
to find should be showing or not. If this finder is not attached to any Robot
, the component
to find does not have to be showing.T
- the parameterized type of the component to find.root
- the root used as the starting point of the search.label
- the text of the JLabel
associated to the component to find.type
- the type of the component to find.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.findByLabel(String)
,
JLabel.getLabelFor()
,
JLabel.setLabelFor(Component)
,
Robot.settings()
,
Settings.componentLookupScope()
,
ComponentLookupScope
<T extends Component> T findByLabel(Container root, String label, Class<T> type, boolean showing)
Component
by the text of its associated JLabel
and type, in the
hierarchy under the given root.T
- the parameterized type of the component to find.root
- the root used as the starting point of the search.label
- the text of the JLabel
associated 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.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.findByLabel(String)
,
JLabel.getLabelFor()
,
JLabel.setLabelFor(Component)
Component findByName(String name)
Finds a
by name. If this finder is attached to a Component
, it
will use the component lookup scope in the Robot
Robot
's
to determine whether
the component to find should be showing or not. If this finder is not attached to any Settings
Robot
,
the component to find does not have to be showing.
Let's assume we have the
with name "myTextBox";
JTextField
JTextField textbox = new JTextField(); textBox.setName("myTextBox");
To get a reference to this
by its name, we can specify:
JTextField
JTextField 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:
name
- the name of the component to find.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.Robot.settings()
,
Settings.componentLookupScope()
,
ComponentLookupScope
<T extends Component> T findByName(String name, Class<T> type)
Component
by name and type. If this finder is attached to a
Robot
, it will use the component lookup scope in the Robot
's
Settings
to determine whether the component to find should be showing or not. If this finder
is not attached to any Robot
, the component to find does not have to be showing.T
- the parameterized type of the component to find.name
- the name of the component to find.type
- the type of the component to find.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.Robot.settings()
,
Settings.componentLookupScope()
,
ComponentLookupScope
,
findByName(String)
<T extends Component> T findByName(String name, Class<T> type, boolean showing)
Component
by name and type.T
- the parameterized type of the component to find.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.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.findByName(String)
Component findByName(String name, boolean showing)
Component
by name.name
- the name of the component to find.showing
- indicates whether the component to find should be visible (or showing) or not.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.findByName(String)
Component findByName(Container root, String name)
Component
by name, in the hierarchy under the given root. If this finder is attached
to a Robot
, it will use the component lookup scope in the Robot
's
Settings
to determine whether the component to find should be showing or not. If this finder
is not attached to any Robot
, the component to find does not have to be showing.root
- the root used as the starting point of the search.name
- the name of the component to find.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.Robot.settings()
,
Settings.componentLookupScope()
,
ComponentLookupScope
,
findByName(String)
Component findByName(Container root, String name, boolean showing)
Component
by name, in the hierarchy under the given root.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.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.findByName(String)
<T extends Component> T findByName(Container root, String name, Class<T> type)
Component
by name and type, in the hierarchy under the given root. If this finder is
attached to a Robot
, it will use the component lookup scope in the Robot
's
Settings
to determine whether the component to find should be showing or not. If this finder
is not attached to any Robot
, the component to find does not have to be showing.T
- the parameterized type of the component to find.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.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.Robot.settings()
,
Settings.componentLookupScope()
,
ComponentLookupScope
,
findByName(String)
<T extends Component> T findByName(Container root, String name, Class<T> type, boolean showing)
Component
by name and type, in the hierarchy under the given root.T
- the parameterized type of the component to find.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.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.findByName(String)
Component find(ComponentMatcher m)
Component
using the given ComponentMatcher
. The given matcher
will be evaluated in the event dispatch thread. Implementations of ComponentMatcher
do not need to
be concerned about the event dispatch thread.m
- the matcher to use to find the component of interest.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.<T extends Component> T find(GenericTypeMatcher<T> m)
Component
using the given GenericTypeMatcher
. The given matcher
will be evaluated in the event dispatch thread. Implementations of GenericTypeMatcher
do not need to
be concerned about the event dispatch thread.T
- the type of component the given matcher can handle.m
- the matcher to use to find the component of interest.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.<T extends Component> T find(Container root, GenericTypeMatcher<T> m)
Component
using the given GenericTypeMatcher
in the hierarchy
under the given root. The given matcher will be evaluated in the event dispatch thread. Implementations of
GenericTypeMatcher
do not need to be concerned about the event dispatch thread.T
- the type of component the given matcher can handle.root
- the root used as the starting point of the search.m
- the matcher to use to find the component.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.Component find(Container root, ComponentMatcher m)
Component
using the given ComponentMatcher
in the hierarchy
under the given root. The given matcher will be evaluated in the event dispatch thread. Implementations of
ComponentMatcher
do not need to be concerned about the event dispatch thread.root
- the root used as the starting point of the search.m
- the matcher to use to find the component.ComponentLookupException
- if a matching component could not be found.ComponentLookupException
- if more than one matching component is found.Collection<Component> findAll(ComponentMatcher m)
Component
s that match the search criteria specified in the given
ComponentMatcher
.m
- the matcher to use to find the component.Component
s that match the search criteria specified in the given
ComponentMatcher
; or an empty collection, if there are no matching components.Collection<Component> findAll(Container root, ComponentMatcher m)
Component
s under the given root that match the search criteria specified in
the given ComponentMatcher
.root
- the root used as the starting point of the search.m
- the matcher to use to find the component.Component
s under the given root that match the search criteria specified in the given
ComponentMatcher
; or an empty collection, if there are no matching components.<T extends Component> Collection<T> findAll(GenericTypeMatcher<T> m)
Component
s that match the search criteria specified in the given
GenericTypeMatcher
.T
- the generic type of component that this search supports.m
- the matcher to use to find the component.Component
s that match the search criteria specified in the given
GenericTypeMatcher
; or an empty collection, if there are no matching components.<T extends Component> Collection<T> findAll(Container root, GenericTypeMatcher<T> m)
Component
s under the given root that match the search criteria specified in
the given GenericTypeMatcher
.T
- the generic type of component that this search supports.root
- the root used as the starting point of the search.m
- the matcher to use to find the component.Component
s under the given root that match the search criteria specified in the given
GenericTypeMatcher
; or an empty collection, if there are no matching components.boolean includeHierarchyIfComponentNotFound()
ComponentLookupException
should include the current component
hierarchy. The default value is true
.true
if the component hierarchy is included as part of the
ComponentLookupException
message, false
otherwise.void includeHierarchyIfComponentNotFound(boolean newValue)
ComponentLookupException
should include the current component
hierarchy. The default value is true
.newValue
- the new value to set.Copyright © 2007-2012 FEST (Fixtures for Easy Software Testing). All Rights Reserved.