Java ActionListener (actionPerfomed) not working for me : <p>The below is a simple code to learn ActionListener, but I don't really understand what is wrong with the code. The program is not printing anything when any of the component is selected. Any suggestion? Thanks.</p>

<pre><code>public class ComboBoxDemo extends JFrame implements ActionListener{

private String[] str = {"One", "Two", "Three", "Four"};
private String[] d = {"1", "2", "3", "4"};
private JPanel panel;
private JButton button;
private JComboBox cb, cb1;
private int count = 0;

public ComboBoxDemo() { 
    panel = new JPanel();
    button = new JButton("Click");
    setTitle("Demo");
    panel.setLayout(new FlowLayout());
    cb = new JComboBox&lt;String&gt;(str); 
    cb1 = new JComboBox&lt;String&gt;(d);
    panel.add(cb);
    panel.add(cb1);
    panel.add(button);
    getContentPane().add(panel);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(200,200);
    setVisible(true);   
}
public static void main(String[] args) {
    new ComboBoxDemo();
}

@Override
public void actionPerformed(ActionEvent e) {
    if(e.getSource() == button) {
        count = count*2;
        System.out.println(count);
    }
    if(e.getSource() == cb) {
        count++;
        System.out.println(count);
    }
    if(e.getSource() == cb1) {
        count--;
        System.out.println(count);
    }
    }
}
</code></pre>
