Redifining/replacing an ActionListener for a JButton doesn't work
Hello,
I am trying to replace a JButton's ActionListener inside another JButton's ActionListener, but is doesn't seem to work. Here's what I did :
editButton =new JButton(EDIT_BUTTON_TEXT);
editButton.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent event){
//
// Change the Add button's text to "OK" and
// redefine it's action listener
//
addButton.setText(OK_BUTTON_TEXT);
final ActionListener savedAddBtnActionListener = addButton.getActionListeners()[0];
addButton.removeActionListener(savedAddBtnActionListener);
addButton.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent event){
...
...
}
});
}
});
It doesn't change the buttons Text, I posted something similar in a previous post, and the addButton's new ActionListener doesn't work. I tried to print something in the console inside of it to test but nothing is outputted.
Any Ideas anyone?
Thank you,
Gabriel

