как насчет ...
protected JButton x, z, a, b,c;
x = new JButton("add x");
z = new JButton("add z");
a = new JButton("add a");
b = new JButton("add b");
c = new JButton("add c");
x.addActionListener(this);
z.addActionListener(this);
a.addActionListener(this);
b.addActionListener(this);
c.addActionListener(this);
тогда
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource()==x)
{
//do something
}
else if (evt.getSource()==z)
{
//do something
}
else if (evt.getSource()==a)
{
//do something
}
else if (evt.getSource()==b)
{
//do something
}
else if (evt.getSource()==c)
{
//do something
}
}
это всегда работает для меня, но, честно говоря, я не уверен, что это не плохая практика