title: How can I remove JButton from JFrame?
body: <p>I want to remove <code>JButton</code> when user click <code>JButton</code>.</p>
  
  <p>I know that I should use remove method, but it did not work.</p>
  
  <p>How can I do this?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>class Game implements ActionListener {
  
  JFrame gameFrame;
  JButton tmpButton;
  JLabel tmpLabel1, tmpLabel2, tmpLabel3, tmpLabel4;
  
  public void actionPerformed(ActionEvent e) {
      gameFrame.remove(tmpLabel1);
      gameFrame.getContentPane().validate();
      return;
  }
  
  Game(String title) {
      gameFrame = new JFrame(title);
      gameFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      gameFrame.setBounds(100, 100, 300, 500);
      gameFrame.setResizable(false);
      gameFrame.getContentPane().setLayout(null);
  
      tmpLabel4 = new JLabel(new ImageIcon("./images/bomber.jpg"));
      tmpLabel4.setSize(200, 200);
      tmpLabel4.setLocation(50, 100);
      tmpButton = new JButton("Play");
      tmpButton.setSize(100, 50);
      tmpButton.setLocation(100, 350);
      tmpButton.addActionListener(this);
  
      gameFrame.getContentPane().add(tmpLabel4);
      gameFrame.getContentPane().add(tmpButton);
      gameFrame.setVisible(true);
  }
  }
  </code></pre>