I wanted to use a JOptionPane to display a simple message. And it all appears to work fine. But the program never ends. Its not stuck in any obvious loops or similar.
See the simple program below that demonstates the problem
import javax.swing.*; public class MainScreen { public static void main(String[] args) { System.out.println("begin"); JFrame frame = new JFrame("ERROR"); JOptionPane.showMessageDialog(frame,"This is a message"); System.out.println("end"); } }
From the System.out.println statements it can be seen that after the ok button is pressed it runs to the end. But the program doesn't exit. Im running it in the Netbeans IDE if that makes any difference
The only solution i've found on the internet is to put system.exit(0) at the end of the code. But this seems like it would be bad practice. Leaving some remnant of the JOptionPane hanging around clogging up memory then forcing it to close. Is this in fact how its supposed to be done?
Thanks for any help (I presume i'm missing a simple instruction)