public final class JButtonMatcher extends NamedComponentMatcherTemplate<JButton>
JButton
s by name, text or visibility on the screen.Modifier and Type | Method and Description |
---|---|
JButtonMatcher |
andShowing()
Indicates that the
JButton to match should be showing on the screen. |
JButtonMatcher |
andText(Pattern textPattern)
Specifies the text to match.
|
JButtonMatcher |
andText(String newText)
Specifies the text to match.
|
static JButtonMatcher |
any()
Creates a new
JButtonMatcher that matches any JButton . |
protected boolean |
isMatching(JButton button)
Indicates whether the name and text of the given
JButton match the ones in this matcher. |
String |
toString() |
static JButtonMatcher |
withName(String name)
Creates a new
JButtonMatcher that matches a JButton by name: |
static JButtonMatcher |
withText(Pattern pattern)
Creates a new
JButtonMatcher that matches a JButton by text. |
static JButtonMatcher |
withText(String text)
Creates a new
JButtonMatcher that matches a JButton by text. |
anyValue, arePropertyValuesMatching, isNameMatching, name, quoted, quotedName
matches, supportedType
requireShowing, requireShowing, requireShowingMatches, reset
@Nonnull public static JButtonMatcher withName(@Nullable String name)
Creates a new JButtonMatcher
that matches a JButton
by name:
The following code listing shows how to match a JButton
by name and text:
JButtonMatcher m =withName
("ok").andText
("OK");
The following code listing shows how to match a JButton
, that should be showing on the screen, by name and
text:
JButtonMatcher m =withName
("ok").andText
("OK").andShowing
();
name
- the name to match.@Nonnull public static JButtonMatcher withText(@Nullable String text)
Creates a new JButtonMatcher
that matches a JButton
by text.
The following code listing shows how to match a JButton
by text:
JButtonMatcher m = withText
("OK");
The following code listing shows how to match a JButton
, that should be showing on the screen, by text:
JButtonMatcher m =withText
("OK").andShowing
();
text
- the text to match. It can be a regular expression.@Nonnull public static JButtonMatcher withText(@Nonnull Pattern pattern)
Creates a new JButtonMatcher
that matches a JButton
by text.
The following code listing shows how to match a JButton
by text, using a regular expression pattern:
JButtonMatcher m = withText
(Pattern.compile("O.*"));
The following code listing shows how to match a JButton
, that should be showing on the screen, by text,
using a regular expression pattern:
JButtonMatcher m =withText
(Pattern.compile("O.*")).andShowing
();
pattern
- the regular expression pattern to match.public static JButtonMatcher any()
JButtonMatcher
that matches any JButton
.@Nonnull public JButtonMatcher andText(@Nullable String newText)
withText(String)
or
withText(Pattern)
, this method will simply update the text to match.newText
- the new text to match. It can be a regular expression.public JButtonMatcher andText(@Nonnull Pattern textPattern)
withText(String)
or
withText(Pattern)
, this method will simply update the text to match.textPattern
- the regular expression pattern to match.@Nonnull public JButtonMatcher andShowing()
JButton
to match should be showing on the screen.@RunsInCurrentThread protected boolean isMatching(@Nonnull JButton button)
Indicates whether the name and text of the given JButton
match the ones in this matcher.
Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT). Client code must call this method from the EDT.
isMatching
in class GenericTypeMatcher<JButton>
button
- the JButton
to match.true
if the JButton
matches the search criteria in this matcher.Copyright © 2014–2019 AssertJ. All rights reserved.