Java examples for Swing:Event
Listening for a Property Change Event
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.JButton; public class Main { public void m() { // Register for property change events on the bean JButton bean = new JButton(); bean.addPropertyChangeListener(new MyPropertyChangeListener()); }/* w ww . ja v a 2 s . com*/ class MyPropertyChangeListener implements PropertyChangeListener { public void propertyChange(PropertyChangeEvent evt) { // Get the old value of the property Object oldValue = evt.getOldValue(); // Get the new value of the property Object newValue = evt.getNewValue(); } } }