Package org.fest.swing.finder
Class JFileChooserFinder
java.lang.Object
org.fest.swing.finder.ComponentFinderTemplate<JFileChooser>
org.fest.swing.finder.JFileChooserFinder
Understands a finder for
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
by name, using the default lookup time (5
seconds):
JFileChooser
JFileChooserFixture fileChooser = JFileChooserFinder.findFileChooser().using(robot);
Where robot
is an instance of
.
Robot
This example shows how to find a
by type using a lookup time of 10 seconds:
JFileChooser
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
using a JFileChooser
:
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);
-
Field Summary
Fields inherited from class org.fest.swing.finder.ComponentFinderTemplate
TIMEOUT
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a newJFileChooserFinder
.protected
JFileChooserFinder
(String name) Creates a newJFileChooserFinder
.protected
JFileChooserFinder
(GenericTypeMatcher<? extends JFileChooser> matcher) Creates a newJFileChooserFinder
. -
Method Summary
Modifier and TypeMethodDescriptionprotected JFileChooser
Casts the givenComponent
to
.JFileChooser
static JFileChooserFinder
Creates a new
capable of looking up aJFileChooserFinder
.JFileChooser
static JFileChooserFinder
findFileChooser
(String name) Creates a new
capable of looking up aJFileChooserFinder
by name.JFileChooser
static JFileChooserFinder
findFileChooser
(GenericTypeMatcher<? extends JFileChooser> matcher) Creates a new
capable of looking up aJFileChooserFinder
using the given matcher.JFileChooser
Finds a
by name or type.JFileChooser
withTimeout
(long timeout) Sets the timeout for this finder.withTimeout
(long timeout, TimeUnit unit) Sets the timeout for this finder.Methods inherited from class org.fest.swing.finder.ComponentFinderTemplate
findComponentWith
-
Constructor Details
-
JFileChooserFinder
protected JFileChooserFinder()Creates a newJFileChooserFinder
. This finder looks up a
by type.JFileChooser
-
JFileChooserFinder
Creates a newJFileChooserFinder
.- Parameters:
name
- the name of theFileChooser
to look for.
-
JFileChooserFinder
Creates a newJFileChooserFinder
.- Parameters:
matcher
- specifies the search criteria to use when looking up aJFileChooser
.
-
-
Method Details
-
findFileChooser
Creates a new
capable of looking up aJFileChooserFinder
.JFileChooser
- Returns:
- the created finder.
-
findFileChooser
Creates a new
capable of looking up aJFileChooserFinder
by name.JFileChooser
- Parameters:
name
- the name of the file chooser to find.- Returns:
- the created finder.
-
findFileChooser
public static JFileChooserFinder findFileChooser(GenericTypeMatcher<? extends JFileChooser> matcher) Creates a new
capable of looking up aJFileChooserFinder
using the given matcher.JFileChooser
- Parameters:
matcher
- the given matcher.- Returns:
- the created finder.
-
using
Finds a
by name or type.JFileChooser
- Specified by:
using
in classComponentFinderTemplate<JFileChooser>
- Parameters:
robot
- contains the underlying finding to delegate the search to.- Returns:
- a
JFileChooserFixture
managing the foundJFileChooser
. - Throws:
WaitTimedOutError
- if aJFileChooser
could not be found.
-
withTimeout
Sets the timeout for this finder. The
to find should be found within the given time period.JFileChooser
- Overrides:
withTimeout
in classComponentFinderTemplate<JFileChooser>
- Parameters:
timeout
- the number of milliseconds before stopping the search.- Returns:
- this finder.
- Throws:
IllegalArgumentException
- if the timeout is a negative number.
-
withTimeout
Sets the timeout for this finder. The
to find should be found within the given time period.JFileChooser
- Overrides:
withTimeout
in classComponentFinderTemplate<JFileChooser>
- Parameters:
timeout
- the period of time the search should be performed.unit
- the time unit fortimeout
.- Returns:
- this finder.
- Throws:
NullPointerException
- if the time unit isnull
.IllegalArgumentException
- if the timeout is a negative number.
-
cast
Casts the givenComponent
to
.JFileChooser
- Specified by:
cast
in classComponentFinderTemplate<JFileChooser>
- Parameters:
c
- the givenComponent
.- Returns:
- the given
Component
, casted toJFileChooser
.
-