public class EventController extends MouseAdapter implements ActionListener {
private EventModel model;
private EventView view;
String tableClick;
Events events;
/** Constructor */
public EventController(EventModel myModel, EventView myView){
model = myModel;
view = myView;
}
public void setUpListeners() {
this.view.addEventButton.addActionListener(this);
this.view.addEventMenuItem.addActionListener(this);
this.view.editEventMenuItem.addActionListener(this);
this.view.tableEvent.addMouseListener(this);
}
@Override
public void actionPerformed(ActionEvent e){
Object button = e.getSource();
if(button==this.view.addEventButton) {
setEventDetails();
}
}
@Override
public void mouseClicked(java.awt.event.MouseEvent event) {
int rowSelected = view.tableEvent.getSelectedRow();
//blahblahblah
view.changeDisplay(events);
}
我如何重写keyPressed
KeyListener 类的方法,就像我对 所做的那样mouseClicked
,ActionPerformed
我真的不想重写keyTyped
and keyReleased
,只是keyPressed
自己。交互发生在另一个名为 VIEW 的类中