Answer the question
In order to leave comments, you need to log in
How to change the listener?
Hello everyone
, please tell me how to change the listener of the button?
found this option
ActionListener[] listeners = bu1[i][j].getActionListeners();
for (ActionListener l : listeners) {
bu1[i][j].removeActionListener(l);
}
bu1[i][j].addActionListener(new ActionListener() {
...
});
Answer the question
In order to leave comments, you need to log in
Well, if you don’t want to go through all ActionListeners on all buttons, you could implement an ActionListener that would be hung on all your buttons, and in turn would call the necessary actions along the chain. Let's say he would have one variable, by changing the value of which, it would be possible to change the final actions called.
but I have 100 buttons and all of them need to change the listener.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question