2016-03-26 6 views
1

私のactionPerformedメソッドで私はオブジェクトを複製する "copy()"を呼びますが、コンパイラは私にこのエラーを返します: "java.awt.event.ActionListener;オーバーライドされたメソッドはjava.lang.CloneNotSupportedException "、 私に何ができる?ActionPerformedでCloneNotSupportedExceptionが発生しました

 public void actionPerformed(ActionEvent e){ 
    if (e.getSource() instanceof JButton) { 
     copy(); ... 

は、あなたがそれを処理する必要が

答えて

0

You can not add throwed checked exception to a method while overriding it.

[...] the overriding method should not throw checked exceptions that are new or broader than the ones declared by the overridden method. [...]

ありがとうございました。

@Override 
public void actionPerformed(ActionEvent e) { 
    //code 
    try { 
     copy(); 
    } catch (CloneNotSupportedException cnse) { 
     cnse.printStackTrace(); 
    } 
} 
関連する問題