title: javax.swing.JComboBox cannot be cast to javax.swing.JButton
body: <p>Here's the code I am using:</p>
  
  <pre><code>public void actionPerformed(ActionEvent arg0) {
      JButton buttonPressed = (JButton) arg0.getSource();
      JComboBox selectedOption = (JComboBox) arg0.getSource();
  
      if (buttonPressed.getText() == "Spam!") {
          if(emailModeBoolean)
              sendSpam(sendBox.getText(), "Not Spam", messageBox.getText());
          else
              sendTextMessage(sendBox.getText(), messageBox.getText());
      }
      if(selectedOption.getSelectedItem().toString() == "Phone Mode") {
          emailModeBoolean = false;
      } else if(selectedOption.getSelectedItem().toString() == "Email Mode"){
          emailModeBoolean = true;
      }
  }
  </code></pre>
  
  <p>It throws this error when I try to change the JComboBox from "Phone Mode" to "Email Mode":</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.JComboBox cannot be cast to javax.swing.JButton
  at Spammer.actionPerformed(Spammer.java:77)
  at javax.swing.JComboBox.fireActionEvent(Unknown Source)
  at javax.swing.JComboBox.setSelectedItem(Unknown Source)
  at javax.swing.JComboBox.setSelectedIndex(Unknown Source)
  at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(Unknown Source)
  at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
  at java.awt.Component.processMouseEvent(Unknown Source)
  at javax.swing.JComponent.processMouseEvent(Unknown Source)
  at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(Unknown Source)
  at java.awt.Component.processEvent(Unknown Source)
  at java.awt.Container.processEvent(Unknown Source)
  at java.awt.Component.dispatchEventImpl(Unknown Source)
  at java.awt.Container.dispatchEventImpl(Unknown Source)
  at java.awt.Component.dispatchEvent(Unknown Source)
  at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
  at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
  at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
  at java.awt.Container.dispatchEventImpl(Unknown Source)
  at java.awt.Window.dispatchEventImpl(Unknown Source)
  at java.awt.Component.dispatchEvent(Unknown Source)
  at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
  at java.awt.EventQueue.access$400(Unknown Source)
  at java.awt.EventQueue$3.run(Unknown Source)
  at java.awt.EventQueue$3.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at java.awt.EventQueue$4.run(Unknown Source)
  at java.awt.EventQueue$4.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at java.awt.EventQueue.dispatchEvent(Unknown Source)
  at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.run(Unknown Source)
  </code></pre>
  
  <p>Thanks for any help in advance!</p>