aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes throwing exceptions in actionPerformed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "throwing exceptions in actionPerformed" Watch "throwing exceptions in actionPerformed" New topic
Author

throwing exceptions in actionPerformed

Hung Tang
Ranch Hand

Joined: Feb 14, 2002
Posts: 148
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

Joined: Mar 22, 2002
Posts: 1055
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: throwing exceptions in actionPerformed
 
Similar Threads
How to recognize the ActionEvent in a FocusLost method??
Redirecting Output
throwing exception in actionPerformed(event e)
setAction and addActionListener
Swing