Your code is not complete, but if you mean the actionPerformed
of the ActionListener
interface (swing), you didn't override it.
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)
So if you want to override the actionListener(ActionEvent e)
, your method should look like this:
public void actionPerformed(ActionEvent e){
...
}
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…