A los botones ponles un "nombre" con boton.setActionCommand("el nombre que quieras").
Añade a todos los botones el mismo ActionListener
Código java:
Ver original if (e.getActionCommand().equals("el nombre que quieras") {
.....
}
if (e.getActionCommand().equals("otro nombre de otro boton") {
....
}
....
}
}
Código java:
Ver originalboton1.setActionCommand("el nombre que quieras");
boton1.addActionListener(unAction);
boton2.setActionCommand("otro nombre de otro boton");
boton2.setActionListener(unAction);
Se bueno.