Next, define an interface for objects that listens for stock events. In the example, the interface defines a single method that is called when a stock price is updated. The interface must be named based on the event name, and must extend java.util.EventListener.

public interface StockListener extends java.util.EventListener {
  public void stockPriceUpdated (StockEvent ev);
}

The event source Bean must include the following methods with these exact signatures:

public void addStockListener (StockListener listener);
public void removeStockListener (StockListener listener);

All of the above is taken directly from the JavaBeans specifications.


Copyright © 1997, 2015 Oracle and/or its affiliates. All rights reserved. Legal Notices