I have been able to successfully load another java program (Calculator) within a java program with the following code:

Calculator.main(null)

The program loads successfully but both programs have the code:

addWindowListener(
			new WindowAdapter()
			{
				public void windowClosing(WindowEvent e)
				{
					System.exit(0);
				}
			}
		);

So once I close the Calculator program that I loaded within another java program, both programs close, acting like one program, clicking the close button on the window closes everything.

Anyone know how to tell that both programs are separate programs and that closing the window, (exiting) should not let the main program I load close as well?

That whole block of code simply tells Java to exit the app when the window is closed, so just remove it or each window that should not call System.exit when it is closed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.