title: Java Button disappears after clicking
body: <p>I'm trying to add a button using an JOptionPane in another button, but after I clicked the original button just keeps disappearing. </p>
  
  <p>I've tried adding the JPanel manually instead of using 'handPanelNPC.getHandPanel()' by iterating through the handPanel.buttons but it stil wont work. I've checked the ArrayList size and it is already inserted properly. </p>
  
  <p>LayoutTesting.java</p>
  
  <pre><code>public class LayoutTesting extends JFrame{
      HandPanel handPanelNPC = new HandPanel();
  
      public LayoutTesting(HandPanel handPanel, int type){
          Container pane = getContentPane();
  
          if (type==1){
              handPanelNPC = handPanel;
          }
          pane.setLayout(new BorderLayout());
          pane.add(handPanelNPC.getHandPanel(), BorderLayout.NORTH);
          validate();
          repaint();
      }
  
      public LayoutTesting(){
          Container pane = getContentPane();
  
          pane.setLayout(new BorderLayout());
          pane.add(handPanelNPC.getHandPanel(), BorderLayout.NORTH);
      }
  }
  </code></pre>
  
  <p>HandPanel.java</p>
  
  <pre><code>public class HandPanel implements ActionListener{   
      JFrame frame = null;
      JPanel panel = new JPanel();
      ArrayList&lt;JButton&gt; buttons = new ArrayList&lt;JButton&gt;();
  
      public HandPanel(){
          addNewButton();
          panel.setLayout(new FlowLayout());
          panel.add(buttons.get(0));
      }
  
      public JComponent getHandPanel(){
          panel = new JPanel();
          for(int i=0; i&lt;buttons.size(); i++){
              JButton button = buttons.get(i);
              panel.add(button);
          }
  
          return panel;
      }
  
      public void addNewButton(){
          JButton button = new JButton();
          button.setPreferredSize(new Dimension(40,58));
          button.addActionListener(this);
  
          buttons.add(button);
      }
  
      public void actionPerformed(ActionEvent e) {
        String[] options = {"Summon", "Set", "Add Card"}; 
  
        int messageType = JOptionPane.QUESTION_MESSAGE;
        int code = JOptionPane.showOptionDialog(
          frame, 
          "What would you like to do?", 
          "Card Name", 
          0, messageType, null, 
          options, options[1]);
  
        if (code==2){
          addNewButton();
          LayoutTesting frame = new LayoutTesting(this, 1);
        } 
      }
  }
  </code></pre>
  
  <p>Main.java</p>
  
  <pre><code>public class Main extends JFrame{
      public static void main(String[] args){
           LayoutTesting frame = new LayoutTesting();
  
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           frame.setSize(400, 300);
           frame.setVisible(true);
       }
  }
  </code></pre>