title: Replace many "else if" with something else
body: <p>I am using an ActionListener and have lots of else if statements in order to know which button is pressed and run some code depending on the button.</p>
  
  <p>Is there a way to make the code nicer? I have nearly 10 else if statements following each other, is there something else I could use instead?</p>
  
  <p>Sample of code:</p>
  
  <pre><code>class BtnListener implements ActionListener {   
              @Override
          public void actionPerformed(ActionEvent e) {
              if (e.getSource() == menu.getOpen()) {
                  getFile();
              } else if (e.getSource() == btnPlay) {
  
              } else if (e.getSource() == btnQuit)) {
           }
  }
  </code></pre>
  
  <p>Thanks.</p>