Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2005

Tip: Looking for answers? Try searching our database.

KeyListener with FileNotFound and IO Exceptions

Thread view: 
travis dewolf - 15 Mar 2005 00:50 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.