title: Return the choice from an array of buttons
body: <p>I've got an array that creates buttons from A-Z, but I want to use it in a 
  Method where it returns the button pressed.</p>
  
  <p>this is my original code for the buttons:</p>
  
  <pre><code>String  b[]={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
  for(i = 0; i &lt; buttons.length; i++)
  {
      buttons[i] = new JButton(b[i]);
      buttons[i].setSize(80, 80);
      buttons[i].setActionCommand(b[i]);
      buttons[i].addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e) {
              String choice = e.getActionCommand();
              JOptionPane.showMessageDialog(null, "You have clicked: "+choice);
          }
      });
      panel.add(buttons[i]);
  }
  </code></pre>