I have a Jbutton that when pressed creates another button and the new button is added to the panel. How to I add an actionListener to the new button?
For example:
The newButton
instance needs to have its actionPerformed
method filled out. I see that you have an ActionListener
added to the button, but that just means that someone is listing for actions. The code you show above doesn't define any actions on that newButton
, so therefore there's no events being fired, and the ActionListener
never gets notified of anything.