First, create an object that represents the event. The class name of the event is based on the event name, which in this case is stock
. Thus, the event is called StockEvent
:
public class StockEvent extends java.util.EventObject { String symbol; double price; public StockEvent (Object source, String symbol, double price) { super (source); this.symbol = symbol; this.price = price; } public String getSymbol () { return symbol; } public double getPrice () { return price; } }