So, I'm trying to make a popup message appear when something happens, but I want the code to continue as soon as the message appears, and not wait for the user to press the okay button.
JOptionPane.showMessageDialog(null, message, "Alert!", JOptionPane.ERROR_MESSAGE);
System.out.println("HI!");
When I do this, it doesn't print HI! until I press okay. How can I fix this?
You can create separate thread and invoke JOptionPane.showMessageDialog
from it:
new Thread(new Runnable(){
public void run() {
JOptionPane.showMessageDialog(null, "message", "Alert!",
JOptionPane.ERROR_MESSAGE);
}
}).start();
System.out.println("HI!");