public class JFileChooserFinder extends ComponentFinderTemplate<JFileChooser>
Looks up JFileChooser
s. Lookups are performed till a file chooser is found, or until the given time to
perform the lookup is over. The default lookup time is 5 seconds.
This example illustrates finding a JFileChooser
by name, using the default lookup time (5 seconds):
JFileChooserFixture fileChooser = JFileChooserFinder.findFileChooser().using(robot);
Where robot
is an instance of Robot
.
This example shows how to find a JFileChooser
by type using a lookup time of 10 seconds:
JFileChooserFixture fileChooser = JFileChooserFinder.findFileChooser().withTimeout(10000).using(robot);
We can also specify the time unit:
JFileChooserFixture fileChooser = JFileChooserFinder.findFileChooser().withTimeout(10, SECONDS
).using(robot);
This examples shows how to find a JFileChooser
using a GenericTypeMatcher
:
GenericTypeMatcher<JFileChooser> matcher = new GenericTypeMatcher<JFileChooser>() { protected boolean isMatching(JFileChooser fileChooser) { return fileChooser.getCurrentDirectory().getAbsolutePath().equals("c:\\temp"); } }; JFileChooserFixture fileChooser = JFileChooserFinder.findFileChooser(matcher).using(robot);
Modifier | Constructor and Description |
---|---|
protected |
JFileChooserFinder()
Creates a new
JFileChooserFinder . |
protected |
JFileChooserFinder(GenericTypeMatcher<? extends JFileChooser> matcher)
Creates a new
JFileChooserFinder . |
protected |
JFileChooserFinder(String name)
Creates a new
JFileChooserFinder . |
Modifier and Type | Method and Description |
---|---|
protected JFileChooser |
cast(Component c)
Casts the given AWT or Swing
Component to JFileChooser . |
static JFileChooserFinder |
findFileChooser()
Creates a new
JFileChooserFinder capable of looking up a JFileChooser . |
static JFileChooserFinder |
findFileChooser(GenericTypeMatcher<? extends JFileChooser> matcher)
Creates a new
JFileChooserFinder capable of looking up a JFileChooser using the given matcher. |
static JFileChooserFinder |
findFileChooser(String name)
Creates a new
JFileChooserFinder capable of looking up a JFileChooser by name. |
JFileChooserFixture |
using(Robot robot)
Finds a
JFileChooser by name or type. |
JFileChooserFinder |
withTimeout(long timeout)
Sets the timeout for this finder.
|
JFileChooserFinder |
withTimeout(long timeout,
TimeUnit unit)
Sets the timeout for this finder.
|
findComponentWith
protected JFileChooserFinder()
JFileChooserFinder
. This finder looks up a JFileChooser
by type.protected JFileChooserFinder(@Nullable String name)
JFileChooserFinder
.name
- the name of the FileChooser
to look for.protected JFileChooserFinder(@Nonnull GenericTypeMatcher<? extends JFileChooser> matcher)
JFileChooserFinder
.matcher
- specifies the search criteria to use when looking up a JFileChooser
.@Nonnull public static JFileChooserFinder findFileChooser()
JFileChooserFinder
capable of looking up a JFileChooser
.@Nonnull public static JFileChooserFinder findFileChooser(@Nullable String name)
JFileChooserFinder
capable of looking up a JFileChooser
by name.name
- the name of the file chooser to find.@Nonnull public static JFileChooserFinder findFileChooser(@Nonnull GenericTypeMatcher<? extends JFileChooser> matcher)
JFileChooserFinder
capable of looking up a JFileChooser
using the given matcher.matcher
- the given matcher.@Nonnull public JFileChooserFixture using(@Nonnull Robot robot)
JFileChooser
by name or type.using
in class ComponentFinderTemplate<JFileChooser>
robot
- contains the underlying finding to delegate the search to.JFileChooserFixture
managing the found JFileChooser
.WaitTimedOutError
- if a JFileChooser
could not be found.@Nonnull public JFileChooserFinder withTimeout(@Nonnegative long timeout)
JFileChooser
to find should be found within the given time period.withTimeout
in class ComponentFinderTemplate<JFileChooser>
timeout
- the number of milliseconds before stopping the search.IllegalArgumentException
- if the timeout is a negative number.@Nonnull public JFileChooserFinder withTimeout(@Nonnegative long timeout, @Nonnull TimeUnit unit)
JFileChooser
to find should be found within the given time period.withTimeout
in class ComponentFinderTemplate<JFileChooser>
timeout
- the period of time the search should be performed.unit
- the time unit for timeout
.NullPointerException
- if the time unit is null
.IllegalArgumentException
- if the timeout is a negative number.@Nullable protected JFileChooser cast(@Nullable Component c)
Component
to JFileChooser
.cast
in class ComponentFinderTemplate<JFileChooser>
c
- the given Component
.Component
, casted to JFileChooser
.Copyright © 2014-2015 AssertJ. All Rights Reserved.