abbot.finder
Interface MultiMatcher

All Superinterfaces:
Matcher

public interface MultiMatcher
extends Matcher

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;
    ...
    // Find the widest label with known text
    JLabel label = (JLabel)finder.find(new Matcher() {
        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

Method Summary
 Component bestMatch(Component[] candidates)
          Returns the best match among all the given candidates, or throws an exception if there is no best match.
 
Methods inherited from interface abbot.finder.Matcher
matches
 

Method Detail

bestMatch

public Component bestMatch(Component[] candidates)
                    throws MultipleComponentsFoundException
Returns the best match among all the given candidates, or throws an exception if there is no best match.

Throws:
MultipleComponentsFoundException


Copyright © 2002-2004 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge