• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Performance of Anonymous class

 
Krishnamurthy Dara
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am developing a screen in applets which contains 5 Buttons. I need to handle all buttons action events. For this I have two choices to do.

1.Adding action listeners to all buttons and handling the events in single method called
public void actionPerformed(ActionEvent actionEvent) {} with five if else condition checking.

2.I can write actionPerfomed method for each and every button by using ActionListener() Anonymous Class.
eg: sendButton.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e) {
submit();
}
});

Please suggest me which one is better in terms of different prospects like performance and coding standards......
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic