不是抽象的,并且不覆盖抽象方法actionPerforme [英] is not abstract and does not override abstract method actionPerforme

查看:55
本文介绍了不是抽象的,并且不覆盖抽象方法actionPerforme的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MainDemo不是抽象的,并且不会覆盖ActionListener中的抽象方法actionPerforme(ActionEvent)

MainDemo is not abstract and does not override abstract method actionPerforme (ActionEvent) in ActionListener

我不知道为什么每次编译时都会发生此错误,尽管我重写了方法(ActionPerformed),那么解决方案是什么?

I don't know why this error occurs whenever I compile , although I override the method (ActionPerformed) , so what is the solution?

private void ActionPerformed(ActionEvent evt)throws ClassNotFoundException,   IOException {  
    user.importEvent(jTextField1.getText());

  }  

推荐答案

您的代码不完整,但是如果您是指 ActionListener 接口(摆动)的 actionPerformed ,您没有覆盖它.

Your code is not complete, but if you mean the actionPerformed of the ActionListener interface (swing), you didn't override it.

覆盖方法意味着在相应的接口或超类中定义/重新定义具有该方法相同签名的方法.同样,方法的名称必须大小写相同.(Java中区分大小写的规则)

Overriding a method means to define/redefine a method with the same signature of that method in the corresponding interface or super class. Also the names of the method must be the same case. (Rule of case-sensitivity in java)

因此,如果您想覆盖 actionListener(ActionEvent e),则您的方法应如下所示:

So if you want to override the actionListener(ActionEvent e), your method should look like this:

public void actionPerformed(ActionEvent e){
    ...
}

另一个替代规则是,您不能减少方法的访问修饰符.因此,如果方法的原始访问修饰符受到 protected 的保护,则只能增加对 public 之类的访问权限.这里原始的访问修饰符是 public ,因此您只能使用 public 进行定义,并且不接受 private .

Another rule in overriding is that you cannot reduce the access modifier of a method. So if a method's original access modifier is protected you can only increase the access to something like public. Here the original access modifier is public, so you can only define it with public, and private is not accepted.

这篇关于不是抽象的,并且不覆盖抽象方法actionPerforme的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆