public void shutdown() { setVisible(false); Thread shutdownThread = new Thread( new CatchingRunnable() { public void doRun() throws Exception { control.shutdown(); System.exit(0); } }); shutdownThread.start(); }
public void restart() { log.fatal("robonobo restarting"); Thread restartThread = new Thread( new CatchingRunnable() { public void doRun() throws Exception { // Show a message that we're restarting SwingUtilities.invokeLater( new CatchingRunnable() { public void doRun() throws Exception { String[] butOpts = {"Quit"}; int result = JOptionPane.showOptionDialog( RobonoboFrame.this, "robonobo is restarting, please wait...", "robonobo restarting", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, butOpts, "Force Quit"); if (result >= 0) { // They pressed the button... just kill everything log.fatal("Emergency shutdown during restart... pressing Big Red Switch"); System.exit(1); } } }); // Shut down the controller - this will block until the // controller exits control.shutdown(); // Hide this frame - don't dispose of it yet as this might make // the jvm exit SwingUtilities.invokeLater( new CatchingRunnable() { public void doRun() throws Exception { RobonoboFrame.this.setVisible(false); } }); // Startup a new frame and controller Robonobo.startup(null, cmdLineArgs, false); // Dispose of the old frame RobonoboFrame.this.dispose(); } }); restartThread.setName("Restart"); restartThread.start(); }