title: How do we use event driven programming in Java Swing
body: <p>I've two separate class, ClassA and ClassB
  and there are everything private within either of these classes,
  now when we dispatch any event in ClassB then ClassA should know that some event has been triggered in ClassB.
  i.e.:</p>
  
  <pre><code>ClassA {
      ClassB b = new ClassB();   
  }
  
  ClassB {
      JButton btn = new JButton();
      btn.onClick();
  }
  </code></pre>
  
  <p>Now as you can see that the onClick method has been called in ClassB, then it should be known by ClassA as well.
  Any help would be appreciated. 
  Thanks in advance.</p>