//create an inner class for your action listener
//Then do similar to whats below
/* Your button.addActionListener(
new innerclass action listener(this));
*/
//then create an action performed method that the inner class
//calls. And you can use the Action Event to get the action comand.
btn_actionPerformed(ActionEvent e)
{
String action = e.getActionCommand();
if(action.equals(this.buttons[i].getActionCommand()))
{
whatYouWantToHappenWhenButtonPushed();
}
}
I didnt make this solution very pretty you'll have to try it out and look up the API's probably.
look at the docs
[url]http://java.sun.com/j2se/1.4.2/docs/api/java/util/EventObject.html#getSource()[url]
this method returns an Object
make sure you know what this Object is.
if your listener is registered to only buttons then it should be easy.
think about using this method
[url]http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/AbstractButton.html#setText(java.lang.String)[/url]
but do you understand that you need to do a cast?
crud, hope this looks better
look at the docs
[url]http://java.sun.com/j2se/1.4.2/docs/api/java/util/EventObject.html#getSource()[/url]
this method returns an Object
make sure you know what this Object is.
if your listener is registered to only buttons then it should be easy.
think about using this method
[url]http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/AbstractButton.html#setText(java.lang.String)[/url]
but do you understand that you need to do a cast?