Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8050635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:07:43+00:00 2026-06-05T07:07:43+00:00

I have a Java application that uses swing. I have found a way to

  • 0

I have a Java application that uses swing. I have found a way to catch all uncaught exception in an application (see below). I would like to log a message, show a dialog with a message for the user and kill the application. The problem is, what I’m trying to catch are some swing exceptions. Trying to show a dialog after the exception is caught in the UncaughtExceptionHandler is impossible since the Swing thread is stopped. Is there any way to then show a dialog? Creating a new swing thread or something like this?

Thanks!

Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
    boolean alreadyCaught = false;

    public void uncaughtException(Thread t, Throwable e) {
        if (alreadyCaught)
            return;

        alreadyCaught = true;
        e.printStackTrace();

        //show Dialog
    }
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:07:45+00:00Added an answer on June 5, 2026 at 7:07 am

    It is perfectly possible to show a dialog from the default uncaught exception handler. One of our products is using this mechanism for the last 5 years without any problems.

    We have a workaround for the problem when the EDT is being replaced due to the exception killing the current EDT. Instead of using the regular SwingUtilities#invokeLater to show the dialog, we use

    new Thread( new Runnable() {
          public void run() {
            EventQueue.invokeLater( aRunnable );
          }
        } ).start();
    

    This allows the EDT to be replaced by a new one, and runs the Runnable on the newly created EDT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented an Java Swing application that uses an embedded JavaDB database. The
I have a Java web application that uses a plugin architecture. I would like
We have a desktop application written in Java Swing that currently uses Java Web
I have a Swing application that uses a Java Thread to constantly perform some
I have a few JAVA application that I monitor using JMX. I would like
I have built a Java application that has some dependencies (~10). I would like
I have a Java Swing application that is being used as a cluster application.
I have a simple Swing Java application that performs searches, and the results are
I have a small Java Swing application that I want to rewrite in WPF
I have developed a Java Swing application, which uses the SwingWorker class to perform

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.