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 / General / October 2006

Tip: Looking for answers? Try searching our database.

Throw an exception from actionPerformed() method.

Thread view: 
Asanka - 03 Oct 2006 17:00 GMT
Hi All,

I am developing a Java application with Swing and Oracle. On the way I
want to throw an exception from the actionPerformed() method of an
ActionListener.

But I can't do that because it doesn't implement it in the
ActionListener interfacre. Is there any way to do that.

Say doPopulate populates a table and essentially it wants to throw or
catch SQLException. So I can't call it like this way.

ActionListener act = new ActionListener(){
   public void actionPerformed(ActionEvent ae){
         doPopulate();
    }
};

But I want to throw it some way without catching..

Could you please advice me how to throw that exception (without
catching)..

Many Thanks ...

Asanka Francis...
Michael Rauscher - 03 Oct 2006 17:09 GMT
Asanka schrieb:
> Hi All,
>
[quoted text clipped - 4 lines]
> But I can't do that because it doesn't implement it in the
> ActionListener interfacre. Is there any way to do that.

No.

> Say doPopulate populates a table and essentially it wants to throw or
> catch SQLException. So I can't call it like this way.
>
> ActionListener act = new ActionListener(){
>     public void actionPerformed(ActionEvent ae){
try {
>           doPopulate();
} catch ( SQLException se ) {
    ExceptionHandler.getInstance().handleException( se );
}
>      }
> };

Where ExceptionHandler is an appropriate class.

Bye
Michael
Nigel Wade - 04 Oct 2006 09:54 GMT
> Hi All,
>
[quoted text clipped - 18 lines]
> Could you please advice me how to throw that exception (without
> catching)..

You can't. You have to catch it and handle it.

What do you think the EDT would do with the exception if you actually managed to
get the ActionListener to throw it? How do you think your GUI would behave from
then on?

Signature

Nigel Wade, System Administrator, Space Plasma Physics Group,
           University of Leicester, Leicester, LE1 7RH, UK
E-mail :    nmw@ion.le.ac.uk
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555

Asanka - 10 Oct 2006 16:48 GMT
> > Hi All,
> >
[quoted text clipped - 30 lines]
> E-mail :    nmw@ion.le.ac.uk
> Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555

Hi Nigel,

Actually I wanted to handle it from somewhere else..

But with your reply I got to know that there then there is a
mishappening in the GUI.

Now I think about it again,,

Many Thanks ..

Asanka.


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



©2009 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.