Hello,
I'm trying to write a method that makes a JButton and adds actionlistener but it doesn't work.
The code below is written in a Class that extends JPanel implements ActionListener.
I tried to replace "this" with instance of class but that also didn't work. Can somebody help me out, I wrote this to understand
how addActionListener works. But I can't figure it out
Thanks in advance!
public void setButton(JButton knop, String naam) { knop = new JButton(naam); knop.setBackground(Color.LIGHT_GRAY); knop.setForeground(Color.BLACK); knop.setFont(new Font("Ariel", Font.PLAIN, 20)); knop.addActionListener(this); <<<<<<----- this.add(knop); }