Is there any advantage in doing an ActionListener as an anonymous inner class, like this:
jBtnSelection.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectionButtonPressed(); } } );
versus creating a separate class that implements ActionListener, like this:
public class GeneratePasswordButtonListener implements ActionListener { GeneratePasswordButtonListener(){} @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub } }
And calling it thusly:
btn.addActionListener(new GeneratePasswordButtonListener());
The biggest problem I see is getting a return value from GeneratePasswordButtonListener()
I'm fairly new to Java, and new to the forum, so please forgive me if this has been asked already.


LinkBack URL
About LinkBacks
Reply With Quote
