title: Java - Button in a button
body: <p>I'm making a program with 2 <code>JButton</code>, however I have a MyFrame class and the buttons are in a different class named KnoppenPanel. The problem is, when I do this I will get a <code>JButton</code> in a <code>JButton</code>. So I have my 2 buttons and another Button surrounding these. How do I solve this?</p>
  
  <p>MyFrame:</p>
  
  <pre><code>public class MyFrame extends JFrame {
  
      Uithangbord u = new Uithangbord();
      KnoppenPanel kp = new KnoppenPanel();
  
      public MyFrame() {
          setLayout(new FlowLayout());
  
          add(u);
          add(kp);
  
          setSize(280, 180);
          setVisible(true);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
      }
  }
  
  public class KnoppenPanel extends JButton implements ActionListener {
  private JButton b, b2;
  private JPanel p1;
  
  Uithangbord bord = new Uithangbord();
  
  public KnoppenPanel() {
      p1 = new JPanel();
      add(p1);
  
      b = new JButton("Open");
      p1.add(b);
      b.addActionListener(this);
  
      b2 = new JButton("Gesloten");
      p1.add(b2);
      b2.addActionListener(this);
  }
  
  public void actionPerformed(ActionEvent event) {
      JButton knop = (JButton)(event.getSource());
      if (knop == b) {
          b.setEnabled(false);
          b2.setEnabled(true);
          bord.maakOpen();
      }
      if (knop == b2) {
          b2.setEnabled(false);
          b.setEnabled(true);
          bord.maakGesloten();
      }
  }
  }
  </code></pre>