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
JFileChoosers. 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
ConstructorsModifierConstructorDescriptionprotectedCreates a newJFileChooserFinder.protectedJFileChooserFinder(String name) Creates a newJFileChooserFinder.protectedJFileChooserFinder(GenericTypeMatcher<? extends JFileChooser> matcher) Creates a newJFileChooserFinder. -
Method Summary
Modifier and TypeMethodDescriptionprotected JFileChooserCasts the givenComponentto.JFileChooserstatic JFileChooserFinderCreates a newcapable of looking up aJFileChooserFinder.JFileChooserstatic JFileChooserFinderfindFileChooser(String name) Creates a newcapable of looking up aJFileChooserFinderby name.JFileChooserstatic JFileChooserFinderfindFileChooser(GenericTypeMatcher<? extends JFileChooser> matcher) Creates a newcapable of looking up aJFileChooserFinderusing the given matcher.JFileChooserFinds aby name or type.JFileChooserwithTimeout(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 aby type.JFileChooser -
JFileChooserFinder
Creates a newJFileChooserFinder.- Parameters:
name- the name of theFileChooserto look for.
-
JFileChooserFinder
Creates a newJFileChooserFinder.- Parameters:
matcher- specifies the search criteria to use when looking up aJFileChooser.
-
-
Method Details
-
findFileChooser
Creates a newcapable of looking up aJFileChooserFinder.JFileChooser- Returns:
- the created finder.
-
findFileChooser
Creates a newcapable of looking up aJFileChooserFinderby 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 newcapable of looking up aJFileChooserFinderusing the given matcher.JFileChooser- Parameters:
matcher- the given matcher.- Returns:
- the created finder.
-
using
Finds aby name or type.JFileChooser- Specified by:
usingin classComponentFinderTemplate<JFileChooser>- Parameters:
robot- contains the underlying finding to delegate the search to.- Returns:
- a
JFileChooserFixturemanaging the foundJFileChooser. - Throws:
WaitTimedOutError- if aJFileChoosercould not be found.
-
withTimeout
Sets the timeout for this finder. Theto find should be found within the given time period.JFileChooser- Overrides:
withTimeoutin 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. Theto find should be found within the given time period.JFileChooser- Overrides:
withTimeoutin 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 givenComponentto.JFileChooser- Specified by:
castin classComponentFinderTemplate<JFileChooser>- Parameters:
c- the givenComponent.- Returns:
- the given
Component, casted toJFileChooser.
-