Hello,
I'm coding a game, and when the user presses an arrow key, it calls up a
move character method, which might call an entity interaction method,
which then might call a load map method wich throws a FileNotFound and
IOException. The problem is that the keyPressed function won't let me
throw any exceptions! I have no idea how to work around this, the player
needs to move when the user presses the arrow keys, I'm at a loss.
Any and all help is appreciated,
thanks,
Travis
travis dewolf - 15 Mar 2005 00:56 GMT
> Hello,
> I'm coding a game, and when the user presses an arrow key, it calls up a
[quoted text clipped - 6 lines]
> thanks,
> Travis
nevermind
Rob Kenworthy - 16 Mar 2005 02:21 GMT
Travis,
Event listener interface methods will never have exceptions in their throws
clause because it would be impossible to handle them. These events are
received via the AWT event thread so there is no way to catch them. If you
are calling methods which throw unchecked exceptions you must put them in a
try/catch block. Maybe something like this:
try {
//call to exception throwing method.
}
catch (ExampleException e) {
// log the exception perhaps or...
// display an error message to the user.
}
Hope that helps.
Rob
------------------------------------------------------------
Check out http://jsourcery.com for javadocs and source code.