Package org.fest.swing.finder
Class JOptionPaneFinder
Understands a finder for
JOptionPanes. 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
ConstructorsModifierConstructorDescriptionprotectedCreates a newJOptionPaneFinder.protectedJOptionPaneFinder(GenericTypeMatcher<? extends JOptionPane> matcher) Creates a newJOptionPaneFinder. -
Method Summary
Modifier and TypeMethodDescriptionprotected JOptionPaneCasts the givenComponentto.JOptionPanestatic JOptionPaneFinderCreates a newcapable of looking up aJOptionPaneFinder.JOptionPanestatic JOptionPaneFinderfindOptionPane(GenericTypeMatcher<? extends JOptionPane> matcher) Creates a newcapable of looking up aJOptionPaneFinderusing the given matcher.JOptionPaneFinds aby name or type.JOptionPanewithTimeout(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 aby type.JOptionPane -
JOptionPaneFinder
Creates a newJOptionPaneFinder.- Parameters:
matcher- specifies the search criteria to use when looking up aJOptionPane.
-
-
Method Details
-
findOptionPane
Creates a newcapable of looking up aJOptionPaneFinder.JOptionPane- Returns:
- the created finder.
-
findOptionPane
Creates a newcapable of looking up aJOptionPaneFinderusing the given matcher.JOptionPane- Parameters:
matcher- the given matcher.- Returns:
- the created finder.
-
using
Finds aby name or type.JOptionPane- Specified by:
usingin classComponentFinderTemplate<JOptionPane>- Parameters:
robot- contains the underlying finding to delegate the search to.- Returns:
- a
JOptionPaneFixturemanaging the foundJOptionPane. - Throws:
WaitTimedOutError- if aJOptionPanecould not be found.
-
withTimeout
Sets the timeout for this finder. The window to search should be found within the given time period.- Overrides:
withTimeoutin 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:
withTimeoutin classComponentFinderTemplate<JOptionPane>- Parameters:
timeout- the period of time the search should be performed.unit- the time unit fortimeout.- Returns:
- this finder.
-
cast
Casts the givenComponentto.JOptionPane- Specified by:
castin classComponentFinderTemplate<JOptionPane>- Parameters:
c- the givenComponent.- Returns:
- the given
Component, casted toJFileChooser.
-