97a98,98 > setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); 99,99d99 < winCount++; 198a199,202 > //setVislble(true) must be called before drawing added to desktop, else > //DND will fail. on drawing added before with a NPE. note however that > //a nulldrawingView will not fail because it is never really added to the desltop > setVisible(true); 199,199d198 < //setVisible(true) called. 214a218,218 > endApp();//would prefer a method that allowed cleanup 215,215d217 < exit(); 218a222,222 > endApp();//would prefer a method that allowed cleanup 219,219d221 < exit(); 225,227d227 < < setVisible(true); < toolDone(); 238a239,246 > public void windowOpened(WindowEvent event) { > winCount++; > } > public void windowClosed(WindowEvent event) { > if (--winCount == 0) { > System.exit(0); > } > } 884a893,901 > // int reply = JOptionPane.showConfirmDialog(this, > // "Do you really want to exit?", > // "JHotDraw - Exit" , > // JOptionPane.YES_NO_OPTION, > // JOptionPane.QUESTION_MESSAGE); > // If the confirmation was affirmative, handle exiting. > // if (reply == JOptionPane.YES_OPTION) { > endApp(); > // } 884a903,903 > protected final void endApp(){ 885,885c904,904 < destroy(); --- > destroy(); 886,886d904 < setVisible(false); // hide the JFrame 887,887c905,905 < dispose(); // tell windowing system to free resources --- > // tell windowing system to free resources 888,888c906,906 < winCount--; --- > dispose(); 889,890d906 < if (winCount == 0) { < System.exit(0); 893,893d907 <