public static void showExceptionDialog ( Exception exception , Component parentComponent , String ... additionalMessages ) { String title = exception . getLocalizedMessage ( ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<html><body width='650'>" ) ; sb . append ( "<h2>" ) ; sb . append ( exception . getLocalizedMessage ( ) ) ; sb . append ( "</h2>" ) ; sb . append ( "<p>" ) ; sb . append ( exception . getMessage ( ) ) ; Stream . of ( additionalMessages ) . forEach ( am -> sb . append ( "<p>" + am ) ) ; String htmlMessage = sb . toString ( ) ; JOptionPane . showMessageDialog ( parentComponent , htmlMessage , title , JOptionPane . ERROR_MESSAGE ) ; }
Show exception dialog .