title: How to define different behaviour for different radio buttons - Java's SWT
body: <p>Consider the following code:</p>
  
  <pre><code>public class SWTTest {
  
      public static void main(String[] args) {
  
          Display display=new Display();
          Shell shell=new Shell(display, SWT.DIALOG_TRIM);
  
          Group group=new Group(shell, SWT.SHADOW_ETCHED_OUT);
          group.setText("A group");
  
          Button[] options=new Button[2];
          options[0]=new Button(group, SWT.RADIO);
          options[0].setText("Option 1");
          options[0].setLocation(5, 20);
          options[0].pack();
  
          options[1]=new Button(group, SWT.RADIO);
          options[1].setText("Option 2");
          options[1].setLocation(5, 50);
          options[1].pack();
  
          options[0].addSelectionListener(new SelectionListener() {
  
              @Override
              public void widgetSelected(SelectionEvent e) {
                  System.out.println("Option 1 Selected");                
              }
  
              @Override
              public void widgetDefaultSelected(SelectionEvent e) {
                  // TODO Auto-generated method stub
  
              }
  
          });
  
  
          group.pack();
          shell.open();
          while (!shell.isDisposed()) {
              if (!display.readAndDispatch()) 
                  display.sleep();
          }
          display.dispose();
      }
  }
  </code></pre>
  
  <p>My intention is that whenever option 1 is selected, the <code>widgetSelected(SelectionEvent e)</code> method will be invoked, and <strong>only</strong> then, but the problem is that selecting option 2 <strong>also</strong> invokes the <code>widgetSelected(SelectionEvent e)</code> method, even though I didn't submit option 2 as a listener, nor I implemented the <code>widgetSelected(SelectionEvent e)</code> method for it.<br>
  So what's going on here, and how can I define different behavior for different option selection?  </p>
  
  <hr>
  
  <h3>Edit</h3>
  
  <p>Oh... and one more thing...<br>
  what if I am not interested in implementing the widgetDefaultSelected(SelectionEvent e) method?  Should I just leave it that way?</p>