public class LabelMatcher extends AbstractComponentMatcher
Component
by the text of the associated JLabel
and (optionally) by type.JLabel.getLabelFor()
,
JLabel.setLabelFor(Component)
Constructor and Description |
---|
LabelMatcher(String label)
Creates a new
LabelMatcher . |
LabelMatcher(String label,
boolean requireShowing)
Creates a new
LabelMatcher . |
LabelMatcher(String label,
Class<? extends Component> type)
Creates a new
LabelMatcher . |
LabelMatcher(String label,
Class<? extends Component> type,
boolean requireShowing)
Creates a new
LabelMatcher . |
Modifier and Type | Method and Description |
---|---|
boolean |
matches(Component c)
Indicates whether the given AWT or Swing
Component matches the criteria specified in this matcher: |
String |
toString() |
requireShowing, requireShowing, requireShowingMatches, reset
public LabelMatcher(@Nullable String label)
LabelMatcher
. The AWT or Swing Component
to match does not have to be showing.label
- the text of the label associated to the Component
we are looking for.NullPointerException
- if the given label is null
.IllegalArgumentException
- if the given label is empty.public LabelMatcher(@Nullable String label, boolean requireShowing)
LabelMatcher
.label
- the text of the label associated to the AWT or Swing Component
we are looking for.requireShowing
- indicates if the Component
to match should be showing or not.NullPointerException
- if the given label is null
.IllegalArgumentException
- if the given label is empty.public LabelMatcher(@Nullable String label, @Nonnull Class<? extends Component> type)
LabelMatcher
. The AWT or Swing Component
to match does not have to be showing.label
- the text of the label associated to the Component
we are looking for.type
- the type of the Component
we are looking for.NullPointerException
- if the given label is null
.IllegalArgumentException
- if the given label is empty.NullPointerException
- if the given type is null
.public LabelMatcher(@Nullable String label, @Nonnull Class<? extends Component> type, boolean requireShowing)
LabelMatcher
.label
- the text of the label associated to the AWT or Swing Component
we are looking for.type
- the type of the Component
we are looking for.requireShowing
- indicates if the Component
to match should be showing or not.NullPointerException
- if the given label is null
.IllegalArgumentException
- if the given label is empty.NullPointerException
- if the given type is null
.@RunsInCurrentThread public boolean matches(@Nullable Component c)
Indicates whether the given AWT or Swing Component
matches the criteria specified in this matcher:
JLabel
attached to the Component
to look for matches the text specified in this
matcherComponent
to look for is of the type specified in this matcher (if specified)Component
matches the value specified in this matcherNote: 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.
c
- the Component
to verify.true
if the name and visibility of the given Component
matches the values specified in this
matcher, false
otherwise.Copyright © 2014–2019 AssertJ. All rights reserved.