title: Button didnt work in JTable structure
body: <pre><code>public void actionPerformed(ActionEvent event) {
  
          this.setVisible(false);     //hide current frame
          prevScreen.setVisible(true); //open the prev frame
  
          JMenuItem menu = (JMenuItem) event.getSource(); //error at here
          if (menu == menuItemAdd) {
              addNewRow();
          } else if (menu == menuItemRemove) {
              removeCurrentRow();
          } else if (menu == menuItemRemoveAll) {
              removeAllRows();
          }
  
  
      }
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.JButton cannot be cast to javax.swing.JMenuItem
      at Addnewbook.actionPerformed(Addnewbook.java:109)
      at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
      at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
  </code></pre>
  
  <p>After I insert the button, I cannot add my data into the table; it suddenly close my <code>JTable</code> frame and back to homepage. I've already search through all forum and other web but still cant find the answer. So is there any way to make the button works with the <code>table</code>? Thanks!</p>