How can i catch Event Dispatch Thread (EDT) exceptions?

后端 未结 3 986
北海茫月
北海茫月 2020-11-30 06:37

I am using a class called MyExceptionHandler that implements Thread.UncaughtExceptionHandler to handle normal exceptions in my project.

As

3条回答
  •  盖世英雄少女心
    2020-11-30 07:22

    Summarizing the above... with newer Java you can just do this:

    // Log exceptions thrown on the event dispatcher thread
    SwingUtilities.invokeLater(()
      -> Thread.currentThread().setUncaughtExceptionHandler((thread, t)
      -> this.log.error("exception in event dispatcher thread", t)));
    

提交回复
热议问题