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);
}
如何重寫就像我已經與mouseClicked
完成的KeyListener類的方法keyPressed
,並ActionPerformed
我真的不希望重寫keyTyped
和keyReleased
,只是自己的keyPressed
。交互發生在另一個類中,名爲VIEW重寫許多類的許多方法中的一類
您能告訴我們其他代碼,以便我們可以更好地理解問題嗎?我看不到任何會阻止你使用'@Override public void keyPressed(...)'的東西。 – MathSquared