Code example for EventObject

Methods: getSource

    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 ")
Stop searching for code, let great code find you!  Add Codota to your java IDE