• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

throwing exceptions in actionPerformed

 
Hung Tang
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is this possible? I have a listener class that implements ActionListener. In this class, I implement the actionPerformed method. I will attach the listener class to a button, so whenever I click on the button, the actionPerformed method will be invoked. Now, in this method, there will be code that will throw exceptions (possibly maybe reading a file, IOException) But actionPerformed signature does not allow it to throw exceptions. The compiler keeps on complaining. How do I solve this problem?
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
But actionPerformed signature does not allow it to throw exceptions.

You don't have much of a choice. You must catch your exceptions inside a try catch block and handle everything there since you cannot rethrow the exception.
-anthony
[ March 29, 2002: Message edited by: Anthony Villanueva ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic