Listening to classes in Java
<p>Here is code that I took from a book:    </p>

<pre><code>import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class RandGen extends JFrame implements ActionListener
{
    private JButton genButton;
    private JButton seedButton;
    private JLabel randLabel;
    private JTextField seedText;
    private int randNumber;

    public RandGen() {
        super("Random number generator");

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 

        randNumber = 215;
        randLabel = new JLabel("***   " + randNumber + " ***");

        genButton = new JButton("Generate");
        genButton.addActionListener(this);
        seedButton = new JButton("Set seed");
        seedButton.addActionListener(this);
        seedText = new JTextField();
        seedText.setColumns(10);
        seedText.setText("" + randNumber);

        getContentPane().setLayout(new FlowLayout());
        getContentPane().add(seedText);
        getContentPane().add(seedButton);
        getContentPane().add(genButton);
        getContentPane().add(randLabel);

        pack();
        setVisible(true);
    }

    public void nextRand() {
        if (randNumber % 2 == 0)
            randNumber = randNumber / 2;
        else
            randNumber = randNumber * 3 + 1;

        setRandNumber(randNumber);
    }

    private void setRandNumber(int randnumber) {
        this.randNumber = randNumber;
        randLabel.setText("*** " + this.randNumber + " ***");
    }

    public void actionPerformed(ActionEvent e) {
        if (e.getSource().equals(genButton))
            this.nextRand();

        if (e.getSource().equals(seedButton)) {
            randNumber = Integer.parseInt(seedText.getText());
            setRandNumber(randNumber);
        }
    }

    public static void main(String args[]) {
        RandGen frame = new RandGen();
    }
}
</code></pre>

<p>As I understand it, the <code>RandGen</code> class is "listening" to some changes that appear in <code>seedButton</code> and <code>genButton</code>, and when that happens, apply the <code>actionPerformed</code> and check the source of the event. I don't understand what happens with <code>seedButton</code> and <code>genButton</code>.</p>

<p>Which method do they need to apply in order to inform the listener that something was changed?</p>
