Results 1 to 7 of 7
- 08-31-2009, 07:08 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 9
- Rep Power
- 0
exception error in a ActionListener class
I am having an issue with one of the GUIs I am currently working on. The GUI itself works fine, but the actionlistener tied to it, keeps coming up with exception errors.
The listener is used to create an instance of a seperate class that connects to, accesses, and returns data from a database. All of the database functions are kept within the class, and all its exceptions are handled, etc. However, when I try to code the listener on the gui side, I keep getting compile errors asking for the exceptions being handled in the db class to be added to the actionlistener. If I add them, I get more compiler errors stating that they are not compatible with actionlistener.actionperformed. Can anyone shed some light on this problem?
- 09-03-2009, 05:42 AM #2
Senior Member
- Join Date
- Aug 2009
- Location
- Pittsburgh, PA
- Posts
- 284
- Rep Power
- 4
The default workaround would seem to be the blunderbuss approach:
This should get the code to compile, but needs something more user friendly in the catch-body.Java Code:[INDENT]try { ... } catch (Exception ex) { ex.printStackTrace(); }[/INDENT]
- 09-03-2009, 08:14 AM #3
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
actionPerformed is not allowed to throw checked exceptions. Either handle them or better yet, separate your DB access code from your interface code.
You should certainly not be trying to connect to a database on the EDT.
- 09-03-2009, 07:38 PM #4
Better make separate functions for particular data access .... and call them in actionPerformed...
- 09-03-2009, 07:57 PM #5
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
- 09-04-2009, 02:18 PM #6
Member
- Join Date
- Aug 2009
- Posts
- 9
- Rep Power
- 0
thank you all for the input. It turns out that I had an extra throw clause in my db code that was causing the compiler error to pop up. Once the throw clause was deleted, Everything ran fine. It's always the simple things that cause the biggest problems. . .
- 09-04-2009, 03:07 PM #7
Similar Threads
-
Exception error
By Rose88 in forum New To JavaReplies: 8Last Post: 07-06-2009, 10:22 PM -
Exception error
By jaiminparikh in forum New To JavaReplies: 0Last Post: 03-20-2009, 09:06 PM -
ActionListener Error
By blackstormattack in forum New To JavaReplies: 1Last Post: 03-05-2009, 08:36 AM -
Exception Error need help fixing
By skinnybones in forum New To JavaReplies: 2Last Post: 12-03-2007, 07:14 PM -
JSF error+exception
By Peter in forum SWT / JFaceReplies: 1Last Post: 07-04-2007, 06:29 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks