title: How to remove listener in Eclipse Widget on dispose?
body: <p>I'm making a component in SWT which listens to events in other components. However, when that component is disposed, it is still registered as a listener. I want to know how to get rid of this listener automatically when the this component is being disposed. </p>
  
  <p>Here's what I mean: </p>
  
  <pre><code>public myDialog implements SelectionListener, ModifyListener {
       public Button myButton = new Button();
  
       public myDialog(){//constructor
               anotherPage.someButton.addSelectionListner(this);
               myButton.addSelectionListner(this);
       }
  
       public void widgetSelected(SelectionEvent e){
            if(e.getSource()==anotherPage.someButton){
                 //do something
            }
            else if(e.getSource()==myButton){
                 //do something else
            }
       }
  }
  
      public anotherPage extends AbstractSystemWizardPage{
          public Button someButton=new Button();
          //...
      }
  </code></pre>
  
  <p><code>myDialog</code> listens to both its own button and a button in <code>anotherPage</code>. It doesn't make sense if user decides to dispose <code>myDialog</code> (close the dialog) but it still listens to <code>someButton</code>. How do I remove it on dispose? </p>