public class ClickListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.out.println(e.getSource().setText("Changed"));
}
}
Eclipse tells me that setText()
is undefined for type Object.
This tells me that getSource()
doesn't actually return the JButton object. How do should I do this then? How I change the text of the clicked button without having to set up a bunch of if-statements for all possible buttons?