SOLVED! Thanks all for quick answers, the problem was that i thought that if u catch an exception that u still have to add throws Exception to the header
^^ pretty dumb off me, thanks again!
————————————ORIGINAL POST——-
Hello,
I have a method load(), this method throws IOException’s.
I’m trying to make this:
public void actionPerformed(ActionEvent e){
if(e.getActionCommand().equals("Load")){
load();
}
}
the problem is, I should add throws IOException to the actionPerformed, but if I do so.
I get an error saying: “The class isnt declared abstract or doesn’t override public void actioPerformed()
So you need to work out what you want to happen if
loadthrows anIOException. The method callingactionPerformedisn’t expecting anIOException, so it can’t possibly handle it.Can you handle it, e.g. by displaying an error message and letting the user try again? If so, put a
try/catchblock inactionPerformedand handle it that way.If you can’t, you could catch the exception and wrap it in a
RuntimeException. That’s generally a fairly harsh way of dealing with the exception, but in some cases it’s the best approach. Swing will catch the exception and log it, so in this case it may not be much help… but you may be able to change that default behaviour too.