Package org.fest.swing.finder
Class JOptionPaneFinder
Understands a finder for
JOptionPane
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):
JOptionPane
JOptionPaneFixture optionPane = JOptionPaneFinder.findOptionPane().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:
JOptionPane
JOptionPaneFixture optionPane = JOptionPaneFinder.findOptionPane().withTimeout(10000).using(robot);We can also specify the time unit:
JOptionPaneFixture optionPane = JOptionPaneFinder.findOptionPane().withTimeout(10, SECONDS
).using(robot);
This example shows how to find a
using a JOptionPane
:
GenericTypeMatcher
GenericTypeMatcher<JOptionPane> matcher = new GenericTypeMatcher<JOptionPane>() { protected boolean isMatching(JOptionPane optionPane) { return "A message".equals(optionPane.getMessage()); } }; JOptionPaneFixture optionPane = JOptionPaneFinder.findOptionPane(matcher).using(robot);
-
Field Summary
Fields inherited from class org.fest.swing.finder.ComponentFinderTemplate
TIMEOUT
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a newJOptionPaneFinder
.protected
JOptionPaneFinder
(GenericTypeMatcher<? extends JOptionPane> matcher) Creates a newJOptionPaneFinder
. -
Method Summary
Modifier and TypeMethodDescriptionprotected JOptionPane
Casts the givenComponent
to
.JOptionPane
static JOptionPaneFinder
Creates a new
capable of looking up aJOptionPaneFinder
.JOptionPane
static JOptionPaneFinder
findOptionPane
(GenericTypeMatcher<? extends JOptionPane> matcher) Creates a new
capable of looking up aJOptionPaneFinder
using the given matcher.JOptionPane
Finds a
by name or type.JOptionPane
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
-
JOptionPaneFinder
protected JOptionPaneFinder()Creates a newJOptionPaneFinder
. This finder looks up a
by type.JOptionPane
-
JOptionPaneFinder
Creates a newJOptionPaneFinder
.- Parameters:
matcher
- specifies the search criteria to use when looking up aJOptionPane
.
-
-
Method Details
-
findOptionPane
Creates a new
capable of looking up aJOptionPaneFinder
.JOptionPane
- Returns:
- the created finder.
-
findOptionPane
Creates a new
capable of looking up aJOptionPaneFinder
using the given matcher.JOptionPane
- Parameters:
matcher
- the given matcher.- Returns:
- the created finder.
-
using
Finds a
by name or type.JOptionPane
- Specified by:
using
in classComponentFinderTemplate<JOptionPane>
- Parameters:
robot
- contains the underlying finding to delegate the search to.- Returns:
- a
JOptionPaneFixture
managing the foundJOptionPane
. - Throws:
WaitTimedOutError
- if aJOptionPane
could not be found.
-
withTimeout
Sets the timeout for this finder. The window to search should be found within the given time period.- Overrides:
withTimeout
in classComponentFinderTemplate<JOptionPane>
- Parameters:
timeout
- the number of milliseconds before stopping the search.- Returns:
- this finder.
-
withTimeout
Sets the timeout for this finder. The window to search should be found within the given time period.- Overrides:
withTimeout
in classComponentFinderTemplate<JOptionPane>
- Parameters:
timeout
- the period of time the search should be performed.unit
- the time unit fortimeout
.- Returns:
- this finder.
-
cast
Casts the givenComponent
to
.JOptionPane
- Specified by:
cast
in classComponentFinderTemplate<JOptionPane>
- Parameters:
c
- the givenComponent
.- Returns:
- the given
Component
, casted toJFileChooser
.
-