我的类实现了ActionListener.我在下面实现了以下嵌套类:
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
Run Code Online (Sandbox Code Playgroud)
但是,Eclipse仍然告诉我,我的类必须实现继承的抽象方法ActionListener.actionPerformed(ActionEvent e).你能不能以这种方式在嵌套类中实现覆盖方法?
我试图禁止输入文本框的字符串中的逗号.这是我到目前为止:
[RegularExpression (@"?[^,]*$",
ErrorMessage = "Commas are not allowed in the subtask title. Please remove any and try again")]
Run Code Online (Sandbox Code Playgroud)
这可能是我的第5次或第6次尝试,到目前为止没有任何效果.任何帮助,将不胜感激.