private void doQuit() { boolean ask = false; for (MainActivity ma : all) { if (ma.isDownloading()) { ask = true; break; } } if (ask) { int result = JOptionPane.showConfirmDialog( getRootPane(), "Really quit?", "Downloads in progress", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.NO_OPTION) { return; } } for (MainActivity ma : all) { for (int i = 0; i < downloadList.getComponentCount(); i++) { DownloadView dv = (DownloadView) ma.downloadList.getComponent(i); dv.stopWorker(); } } System.exit(0); }
private boolean isDownloading() { for (int i = 0; i < downloadList.getComponentCount(); i++) { DownloadView dv = (DownloadView) downloadList.getComponent(i); if (dv.isDownloading()) { return true; } } return false; }
private void doClose() { if (isDownloading()) { int result = JOptionPane.showConfirmDialog( getRootPane(), "Really close?", "Downloads in progress", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.NO_OPTION) { return; } for (int i = 0; i < downloadList.getComponentCount(); i++) { DownloadView dv = (DownloadView) downloadList.getComponent(i); dv.stopWorker(); } } all.remove(this); setVisible(false); if (all.size() == 0) { System.exit(0); } }