????????????????????????????

/*
 * ????????????????????????????????????
 */
interface InterestingEvent {
    
    public void interestingEvent();
    
}
 
 
class EventNotifier {
    
    private InterestingEvent ie;        //д??private List<InterestingEvent> eventList?????????????
    private boolean somethingHappened;
    
    public EventNotifier(InterestingEvent ie) {
        this.ie = ie;
        this.somethingHappened = false;
    }
    
    public void setHappened() {
        this.somethingHappened = true;
    }
    
    public void doWork() {
        if (somethingHappened) {
            ie.interestingEvent();
        }
    }
    
}
 
 
class ButtonPressedEvent implements InterestingEvent {
 
    @SuppressWarnings("unused")
    private EventNotifier en;
    
    public ButtonPressedEvent() {
        en = new EventNotifier(this);
    }
    
    public void interestingEvent() {
        System.out.println("button pressed ");
    }
    
}
 
 
class EventNotifierTest {
    
    public static void test() {
        //????????????÷????????е??????????????????????????“???Client????”???????
        EventNotifier en = new EventNotifier(new ButtonPressedEvent());
        en.setHappened();
        en.doWork();
        
        EventNotifier en2 = new EventNotifier(new InterestingEvent(){
            public void interestingEvent() {
                System.out.println("inputtext change ");
            }
        });
        en2.setHappened();
        en2.doWork();
        
    }
}
 
 
//????????????????
public class JavaInterfaceCallBack {
    
    public static void main(String[] args) {
       
        ChangeNameTest.test();
        EventNotifierTest.test();
        
    }
 
}