I have been told by my teacher that having a separate class for the actionListener
is best. In the separate class, should I just make one actionListener method eg.
public void actionPerformed(ActionEvent e) {
if(e.getSource() == myButton) {
//do something
}
else if(e.getSource() == myComboBox) {
//do something
}
}
or should I make many? I have a feeling I should make many but I have no idea how to go about it. What would the different parameters be? I will be making an instance of this class in my View class where the button and combobox is. (this would be the Controller class as i'm trying to do MVC)
For the button I would like for the background to change colour when the mouse hovers over it and then of course do something when clicked. The combobox simply needs to return whatever option was selected as String.