Class JButtonMatcher
- All Implemented Interfaces:
ComponentMatcher
,ResettableComponentMatcher
JButton
by name, text and visibility on the screen.-
Field Summary
FieldsFields inherited from class org.fest.swing.core.matcher.NamedComponentMatcherTemplate
ANY, name
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionIndicates that the
to match should be showing on the screen.JButton
Specifies the text to match.Specifies the text to match.static JButtonMatcher
any()
Creates a new
that matches anyJButtonMatcher
.JButton
protected boolean
isMatching
(JButton button) Indicates whether: the name of the givenJButton
is equal to the name in this matcher, and the text of the givenJButton
matches the text (or pattern) in this matchertoString()
static JButtonMatcher
Creates a new
that matches aJButtonMatcher
that: has a matching name (optionally) has matching text (optionally) is showing on the screenJButton
static JButtonMatcher
Creates a new
that matches aJButtonMatcher
by its text.JButton
static JButtonMatcher
Creates a new
that matches aJButtonMatcher
by its text.JButton
Methods inherited from class org.fest.swing.core.matcher.NamedComponentMatcherTemplate
arePropertyValuesMatching, isNameMatching, quoted, quotedName
Methods inherited from class org.fest.swing.core.GenericTypeMatcher
matches, supportedType
Methods inherited from class org.fest.swing.core.AbstractComponentMatcher
requireShowing, requireShowing, requireShowingMatches, reset
-
Field Details
-
text
-
-
Constructor Details
-
JButtonMatcher
-
-
Method Details
-
withName
Creates a new
that matches aJButtonMatcher
that:JButton
- has a matching name
- (optionally) has matching text
- (optionally) is showing on the screen
The following code listing shows how to match a
by name and text:JButton
JButtonMatcher m =
withName
("ok").andText
("OK");The following code listing shows how to match a
, that should be showing on the screen, by name and text:JButton
JButtonMatcher m =
withName
("ok").andText
("OK").andShowing
();- Parameters:
name
- the name to match.- Returns:
- the created matcher.
-
withText
Creates a new
that matches aJButtonMatcher
by its text.JButton
The following code listing shows how to match a
by text:JButton
JButtonMatcher m =
withText
("OK");The following code listing shows how to match a
, that should be showing on the screen, by text:JButton
JButtonMatcher m =
withText
("OK").andShowing
();- Parameters:
text
- the text to match. It can be a regular expression.- Returns:
- the created matcher.
-
withText
Creates a new
that matches aJButtonMatcher
by its text.JButton
The following code listing shows how to match a
by text, using a regular expression pattern:JButton
JButtonMatcher m =
withText
(Pattern.compile("O.*"));The following code listing shows how to match a
, that should be showing on the screen, by text, using a regular expression pattern:JButton
JButtonMatcher m =
withText
(Pattern.compile("O.*")).andShowing
();- Parameters:
textPattern
- the regular expression pattern to match.- Returns:
- the created matcher.
- Since:
- 1.2
-
any
Creates a new
that matches anyJButtonMatcher
.JButton
- Returns:
- the created matcher.
-
andText
Specifies the text to match. If this matcher was created using
orwithText(String)
, this method will simply update the text to match.withText(Pattern)
- Parameters:
newText
- the new text to match. It can be a regular expression.- Returns:
- this matcher.
-
andText
Specifies the text to match. If this matcher was created using
orwithText(String)
, this method will simply update the text to match.withText(Pattern)
- Parameters:
textPattern
- the regular expression pattern to match.- Returns:
- this matcher.
- Since:
- 1.2
-
andShowing
Indicates that the
to match should be showing on the screen.JButton
- Returns:
- this matcher.
-
isMatching
Indicates whether:- the name of the given
JButton
is equal to the name in this matcher, and - the text of the given
JButton
matches the text (or pattern) in this matcher
Note: This method is not executed in the event dispatch thread (EDT.) Clients are responsible for invoking this method in the EDT.
- Specified by:
isMatching
in classGenericTypeMatcher<JButton>
- Parameters:
button
- theJButton
to match.- Returns:
true
if theJButton
matches the search criteria in this matcher.
- the name of the given
-
toString
-