All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.awt.Component | +----java.awt.TextComponent | +----java.awt.TextField | +----sunw.demo.misc.ChangeReporter
import sunw.demo.misc.OurButton; import sunw.demo.misc.ChangeReporter; import java.awt.*; import java.beans.*; public class DemoChangeReporter { OurButton button = new OurButton(); ChangeReporter reporter = new ChangeReporter(); PropertyChangeAdapter adapter = new PropertyChangeAdapter(); DemoChangeReporter() { button.addPropertyChangeListener(adapter); button.setLabel("Report This"); Frame f = new Frame("Demo Change Reporter"); f.setLayout(new FlowLayout()); f.add(button); f.add(reporter); f.pack(); f.show(); } class PropertyChangeAdapter implements PropertyChangeListener { public void propertyChange(PropertyChangeEvent e) { reporter.reportChange(e); } } public static void main(String[] argv) { new DemoChangeReporter(); } }In the example above, the button is connected to the ChangeReporter with a (nested) adpater class. When the DemoChangeReporter object is constructed the buttons label field is set, and the adapters propertyChange method runs.
public ChangeReporter()
public void reportChange(PropertyChangeEvent evt)
All Packages Class Hierarchy This Package Previous Next Index