javapublic class Main {
    public static void main(String[] args) {
        User user = new User();
        PropertyChangeSupport change = new PropertyChangeSupport(user);
        change.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                System.out.println(evt.getPropertyName());
            }
        });
change.firePropertyChange("name","1", "2");
System.out.println(user);
    }
}

happyfish
2.4k 声望66 粉丝

[链接]