title: Java Swing More efficient event broadcasting
body: <p>I want to be able to have a canvas component that adds spots to places where the user double clicks, when a spot is added, and then I want to be able to notify the listbox placed in the main frame that a spot has been added. 
  My knowledge of event broadcasting is poor, is there a better way of doing this?</p>
  
  <p>Main class: initialize drawing component:
  will this be best for an unnamed inner class?</p>
  
  <pre><code>private JList lbx;
  private DefaultListModel&lt;String&gt; lbxModel;
  private DrawComp draw;
  public static void main(String args[]) {
  draw.addListener(new DrawCompListener() {
  
              @Override
              public void spotAdded(DrawComp source, Spot spot) {
                  lbxModel.addElement("spot+" added");
              }
          });
  }
  </code></pre>
  
  <p>interface that will be passed through to the queue:</p>
  
  <pre><code>public interface DrawCompListener {
      void spotAdded(DrawComp source, Spot spot);
  </code></pre>
  
  <p>Queue Class that will implement the interface: (should this be here?)</p>
  
  <pre><code>public class DrawCompListenerQueue implements DrawCompListener {
      private ArrayList&lt;DrawCompListener&gt; listeners = new ArrayList&lt;DrawCompListener&gt;();
  
      public void addListener(DrawCompListener listener) {
          listeners.add(listener);
      }
  @Override
      public void spotAdded(DrawComp source, Spot spot) {
          for(DrawCompListener listener : listeners) {
              listener.spotAdded(source, spot);
          }
      }
  </code></pre>
  
  <p>The actual drawing component to place the spots and pass through the info to the main class for the Jlist</p>
  
  <pre><code>public class DrawComp extends JPanel implements MouseListener {     
      private Vector&lt;Spot&gt; spots = new Vector&lt;Spot&gt;();    
      private DrawCompListenerQueue listenerQ = new DrawCompListenerQueue();    
      public void addListener(DrawCompListener listener) {
          listenerQ.addListener(listener);
      } 
  </code></pre>
  
  <p>adding a spot:</p>
  
  <pre><code>public void mouseClicked(MouseEvent e) {
          // left-click = add spot
          if ((e.getButton() == MouseEvent.BUTTON1) &amp;&amp; (e.getClickCount() == 2)) {
              // add spot
              Spot s = new Spot();
              s.p = e.getPoint();
              spots.add(s);
              repaint();
  
              // notify listeners
              listenerQ.spotAdded(this, s);   
  </code></pre>