Lớp của tôi triển khai ActionListener. Tôi đã thực hiện các lớp lồng nhau sau đây:Phải triển khai phương pháp trừu tượng được thừa kế
JMenuItem mntmNew = new JMenuItem("New...");
mntmNew.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e){
doNew(e); //calls to outer class for cleaner code
}
});
mnFile.add(mntmNew);
JMenuItem mntmLoad = new JMenuItem("Load...");
mntmLoad.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e){
doLoad(e); //calls to outer class for cleaner code
}
});
mnFile.add(mntmLoad);
//etc. for the rest of the menu system
Tuy nhiên, Eclipse vẫn nói với tôi rằng lớp học của tôi phải thực hiện những kế thừa phương pháp trừu tượng ActionListener.actionPerformed (ActionEvent e). Bạn có thể không thực hiện các phương thức ghi đè trong một lớp lồng nhau theo cách này không?
Đã hủy bỏ phiếu bầu với một cuộc bỏ phiếu. Tôi không chắc tại sao một người nào đó đã bỏ phiếu cho câu hỏi này vì nó dường như là một câu hỏi hợp lệ đối với tôi. –
++ vì câu trả lời của @ HovercraftFullOfEels :) – Azad