You class is extending JButton
. Then when you add your JPanel
(with 2 JButton
) you are adding this in a JButton
.
I think what do you want is the KnoppenPanel have only the 2 JButtons
then you just need to change:
public class KnoppenPanel extends JButton implements ActionListener {
By
public class KnoppenPanel extends JPanel implements ActionListener {
If you do this change, you can also directly add the JButton in the KnoppenPanel like that:
public KnoppenPanel() {
b = new JButton("Open");
add(b);
b.addActionListener(this);
b2 = new JButton("Gesloten");
add(b2);
b2.addActionListener(this);
}