Question

I have a Java swing launcher program to launch another class (running its main method). Each program has its cancel button to exit itself.

I use System.exit(0); when this cancel button is pressed.

The launcher program does this in actionPerformed:

if (source==carMenuItem) {
    ta.append("Car launched\n");
    TestCar.main(par);

}
if (source==DialogboxMenuItem) {
    ta.append("Dialogbox launched\n");            
    DialogBox.main(par);
}        
if (source==LengthConversionMenuItem) {
    ta.append("LengthConversion launched\n");            
    LengthConversion.main(par);           
}

When I press the program's cancel button, it also closes my launcher program. How can I avoid this situation?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top