public class JOptionPaneFinder extends ComponentFinderTemplate<JOptionPane>
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 JOptionPane by name, using the default lookup time (5 seconds):
JOptionPaneFixture optionPane = JOptionPaneFinder.findOptionPane().using(robot);
Where robot is an instance of Robot.
This example shows how to find a JOptionPane by type using a lookup time of 10 seconds:
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 JOptionPane using a 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);
| Modifier | Constructor and Description |
|---|---|
protected |
JOptionPaneFinder()
Creates a new
JOptionPaneFinder. |
protected |
JOptionPaneFinder(GenericTypeMatcher<? extends JOptionPane> matcher)
Creates a new
JOptionPaneFinder. |
| Modifier and Type | Method and Description |
|---|---|
protected JOptionPane |
cast(Component c)
Casts the given AWT or Swing
Component to JOptionPane. |
static JOptionPaneFinder |
findOptionPane()
Creates a new
JOptionPaneFinder capable of looking up a JOptionPane. |
static JOptionPaneFinder |
findOptionPane(GenericTypeMatcher<? extends JOptionPane> matcher)
Creates a new
JOptionPaneFinder capable of looking up a JOptionPane using the given matcher. |
JOptionPaneFixture |
using(Robot robot)
Finds a
JOptionPane by name or type. |
JOptionPaneFinder |
withTimeout(long timeout)
Sets the timeout for this finder.
|
JOptionPaneFinder |
withTimeout(long timeout,
TimeUnit unit)
Sets the timeout for this finder.
|
findComponentWithprotected JOptionPaneFinder()
JOptionPaneFinder. This finder looks up a JOptionPane by type.protected JOptionPaneFinder(@Nonnull GenericTypeMatcher<? extends JOptionPane> matcher)
JOptionPaneFinder.matcher - specifies the search criteria to use when looking up a JOptionPane.@Nonnull public static JOptionPaneFinder findOptionPane()
JOptionPaneFinder capable of looking up a JOptionPane.@Nonnull public static JOptionPaneFinder findOptionPane(@Nonnull GenericTypeMatcher<? extends JOptionPane> matcher)
JOptionPaneFinder capable of looking up a JOptionPane using the given matcher.matcher - the given matcher.@Nonnull public JOptionPaneFixture using(@Nonnull Robot robot)
JOptionPane by name or type.using in class ComponentFinderTemplate<JOptionPane>robot - contains the underlying finding to delegate the search to.JOptionPaneFixture managing the found JOptionPane.WaitTimedOutError - if a JOptionPane could not be found.@Nonnull public JOptionPaneFinder withTimeout(@Nonnegative long timeout)
withTimeout in class ComponentFinderTemplate<JOptionPane>timeout - the number of milliseconds before stopping the search.@Nonnull public JOptionPaneFinder withTimeout(@Nonnegative long timeout, @Nonnull TimeUnit unit)
withTimeout in class ComponentFinderTemplate<JOptionPane>timeout - the period of time the search should be performed.unit - the time unit for timeout.@Nullable protected JOptionPane cast(@Nullable Component c)
Component to JOptionPane.cast in class ComponentFinderTemplate<JOptionPane>c - the given Component.Component, casted to JFileChooser.Copyright © 2014 AssertJ. All rights reserved.