I have a GUI class, GUIView, with a no-arg constructor and a static getInstance() method.
The GUI class has a JButton called btnB1 with a method:
void addB1Listener(ActionListener al){
btnB1.addActionListener(al);
}
The Controller class has an instance of the GUI and the Model.
The Controller has a constructor which assigns a new ActionListener to the JButton from the GUI.
private GUI m_gui;
FTController(GUIView view){
m_gui = view;
m_gui.addButtonListener(new AddButtonListener());
}
The Controller has an inner class:
class AddButtonListener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
// do stuff
}
}
The model has a constructor which accepts a GUIView.
My main method setups instances of the objects:
private GUIView view;
private Model model;
private Controller controller;
public static void main(String [] args){
view = GUIView.getInstance();
model = new Model(view);
controller = new Controller(view);
}
This action listener for btnB1 is firing multiple times, but I don't understand why.
Edited by: user10199598 on Jan 9, 2012 2:56 PM