Provides methods for determining the best match among a group of matching
components.
For use with implementations of
ComponentFinder .
You can conveniently inline a custom matcher like so:
ComponentFinder finder = BasicFinder.getDefault();
...
// Find the widest label with known text
JLabel label = (JLabel)finder.find(new MultiMatcher() {
public boolean matches(Component c) {
return c instanceof JLabel
&& "OK".equals(((JLabel)c).getText());
}
public Component bestMatch(Component[] candidates)
throws MultipleComponentsFoundException {
Component biggest = candidates[0];
for (int i=1;i < candidates.length;i++) {
if (biggest.getWidth() < candidates[i].getWidth())
biggest = candidates[i];
}
return biggest;
}
});
See Also: ComponentFinder |