97a98 > setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); 99d99 < winCount++; 199c199,202 < //setVisible(true) called. --- > //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); 215c218 < exit(); --- > endApp();//would prefer a method that allowed cleanup 219c222 < exit(); --- > endApp();//would prefer a method that allowed cleanup 225,227d227 < < setVisible(true); < toolDone(); 238a239,246 > public void windowOpened(WindowEvent event) { > winCount++; > } > public void windowClosed(WindowEvent event) { > if (--winCount == 0) { > System.exit(0); > } > } 885,890c893,901 < destroy(); < setVisible(false); // hide the JFrame < dispose(); // tell windowing system to free resources < winCount--; < if (winCount == 0) { < System.exit(0); --- > // 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(); > // } 891a903,906 > protected final void endApp(){ > destroy(); > // tell windowing system to free resources > dispose(); 893d907 <