I'm currently working on a project that's getting more complex than I thought it would be originally. What I'm aiming to do right now is show a message dialog without halting the execution of the main thread in the program. Right now, I'm using:
JOptionPane.showMessageDialog(null, message, "Received Message", JOptionPane.INFORMATION_MESSAGE);
But this pauses everything else in the main thread so it won't show multiple dialogs at a time, just on after the other. Could this m=be as simple as creating a new JFrame instead of using the JOptionPane?
You could just start a separate
Runnable
to display the dialog and handle the response.According to the docs:
The link above shows some examples of creating dialog boxes.
One other option is to start the JOptionPane in its own thread something like this:
That way the main thread of your program continues even though the modal dialog is up.
try this one: