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); } }