I've been developing java programs for 1½ year. I'm currently working on a summer project, that involves quite a big Graphical User Interface.
My GUI consists of several tabbed panes. Each pane has its own class. Each pane has SEVERAL jButtons.
Now, I've come to a point, where there's so many anonymous inner classes (for ActionListeners) in my tabbed-pane classes, that I am certain there must be a better way; if not for efficiency, then for maintainability - it's becoming quite a mess.
My question is this: Is there a better to organize listeners, when you have a lot of them in each class? I've thought about clustering the listeners in relevant classes - like the following sample code:
public class SomeListeners implements ActionListener{
@Override
public void actionPerformed(ActionEvent e){
String command = e.getActionCommand();
switch(command){
case "This button":
doThis();
break;
case "That button":
doThat();
break;
}
}
}
Or might there be an even better way?
Thanks in advance :)