Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: How do I catch a AWT-EventQueue-0

  1. #1
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default How do I catch a AWT-EventQueue-0

    I am using the External Library SmartXLS whenever the trial version expires, I get the following message in my IDE:
    Exception in thread "AWT-EventQueue-0" ZI.CS: This trial version of SmartXLS has timed out.
    Is there a way for me to catch that exception and prompt the user with a JOptionPane or something? I have tried a try/catch statement, but I cannot seem to catch it. Any thoughts?
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How do I catch a AWT-EventQueue-0

    Have you tried to just catch it as a general Exception
    try{
    //do work
    }catch(Exception e){
    //prompt for error
    }finally{
    //final tasks if necessary
    }

  3. #3
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: How do I catch a AWT-EventQueue-0

    I usually always use general Exceptions.

    Where specifically should I put it? I attempted to put it around my main (figured the more vague the better) and I attempted to put it around the area where I use the library elements but both failed to catch it.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How do I catch a AWT-EventQueue-0

    Ah, that last bit of information sheds some light on the subject. If you are calling this from main, and the library starts another thread (eg, an AWT thread in that it uses some sort of GUI), then that is why you can't catch it (the exception is thrown after the function call exits). Not sure of a quick solution off the top of my head.

  5. #5
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: How do I catch a AWT-EventQueue-0

    Actually I have my GUI elements and most of my program in a class called GUI. In the GUI class, I use the library.

    My main just says:
    public static void main(String[] args)
    {
    new Gui();
    }
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  6. #6
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How do I catch a AWT-EventQueue-0

    Doesn't matter...I'm assuming the Exception is being thrown on the EDT. So when you call a function from the library it places an event into the EDT queue and the called method exits, exiting your try/catch block successfully. The EDT continues until the queue reaches the libraries functions, at which point it'll run and throw an exception. This is my assumption based upon the info provided.

  7. #7
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: How do I catch a AWT-EventQueue-0

    So is there anything that can be done about that (it is probably a moot point now since my company may just buy the library, but it good to know for the future).
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Similar Threads

  1. how do i try/catch this?
    By safra in forum Exceptions
    Replies: 6
    Last Post: October 29th, 2011, 11:14 AM
  2. try/catch..help needed soon as possible
    By safra in forum Exceptions
    Replies: 1
    Last Post: September 19th, 2010, 08:46 AM
  3. (while) insted of (try and catch)
    By b109 in forum Java Theory & Questions
    Replies: 6
    Last Post: May 13th, 2010, 09:01 PM
  4. catch all
    By silverspoon34 in forum Exceptions
    Replies: 1
    Last Post: November 29th, 2009, 02:18 PM
  5. try/catch
    By rsala004 in forum Exceptions
    Replies: 5
    Last Post: July 19th, 2009, 03:20 PM