Code example for PropertyChangeEvent

Methods: getNewValue, getOldValue, getPropertyName

0
        p.addPropertyChangeListener(new PropertyChangeListener()
        { 
            @Override 
            public void propertyChange(PropertyChangeEvent evt)
            { 
                System.out.println(evt.getPropertyName() + " change from " + evt.getOldValue() + " to " + evt.getNewValue());
            } 
        }); 
 
        new JFrame() 
        { 
            { 
                setLayout(new GridLayout(0, 1, 3, 3));
                PersonUI ui = new PersonUI();
                ui.setModel(p);
                add(ui);
                ui = new PersonUI();
                ui.setModel(p);
                add(ui);
                setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 
                setVisible(true);