Code example for EventObject

Methods: getSource

0
    public boolean matchesSafely(EventObject item, Description mismatchDescription) {
        if (!eventClass.isInstance(item)) {
          mismatchDescription.appendText("item type was " + item.getClass().getName());
          return false; 
        } 
         
        if (!eventHasSameSource(item)) {
          mismatchDescription.appendText("source was ").appendValue(item.getSource());
          return false; 
        } 
        return true; 
    } 
 
     
    private boolean eventHasSameSource(EventObject ev) {
        return ev.getSource() == source;
    } 
 
    public void describeTo(Description description) {
        description.appendText("an event of type ")
                .appendText(eventClass.getName())