public void exit() { session.close(); if (dnsCache != null) { System.out.printf(" cache= %s%n", dnsCache.toString()); System.out.printf(" cache.size= %d%n", dnsCache.getSize()); System.out.printf(" cache.memorySize= %d%n", dnsCache.getMemoryStoreSize()); Statistics stats = dnsCache.getStatistics(); System.out.printf(" stats= %s%n", stats.toString()); } cacheManager.shutdown(); fileChooser.save(); managePanel.save(); accessLogPanel.save(); servletLogPanel.save(); urlDump.save(); Rectangle bounds = frame.getBounds(); prefs.putBeanObject(FRAME_SIZE, bounds); try { store.save(); } catch (IOException ioe) { ioe.printStackTrace(); } done = true; // on some systems, still get a window close event System.exit(0); }
public static void main(String args[]) throws HTTPException { // prefs storage try { String prefStore = ucar.util.prefs.XMLStore.makeStandardFilename(".unidata", "TdsMonitor.xml"); store = ucar.util.prefs.XMLStore.createFromFile(prefStore, null); prefs = store.getPreferences(); Debug.setStore(prefs.node("Debug")); } catch (IOException e) { System.out.println("XMLStore Creation failed " + e); } // initializations BAMutil.setResourcePath("/resources/nj22/ui/icons/"); // put UI in a JFrame frame = new JFrame("TDS Monitor"); ui = new TdsMonitor(prefs, frame); frame.setIconImage(BAMutil.getImage("netcdfUI")); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { if (!done) ui.exit(); } }); frame.getContentPane().add(ui); Rectangle bounds = (Rectangle) prefs.getBean(FRAME_SIZE, new Rectangle(50, 50, 800, 450)); frame.setBounds(bounds); frame.pack(); frame.setBounds(bounds); frame.setVisible(true); }