Example usage for javax.swing JOptionPane OK_CANCEL_OPTION

List of usage examples for javax.swing JOptionPane OK_CANCEL_OPTION

Introduction

In this page you can find the example usage for javax.swing JOptionPane OK_CANCEL_OPTION.

Prototype

int OK_CANCEL_OPTION

To view the source code for javax.swing JOptionPane OK_CANCEL_OPTION.

Click Source Link

Document

Type used for showConfirmDialog.

Usage

From source file:edu.ku.brc.helpers.EMailHelper.java

/**
 * Asks for a password./*from   w w  w .jav  a  2s  .c  o m*/
 * @param topframe the parent frame
 * @return the password
 */
public static String askForPassword(final Frame topframe) {
    PanelBuilder builder = new PanelBuilder(new FormLayout("p,2px,p", "p,2px,p")); //$NON-NLS-1$ //$NON-NLS-2$
    CellConstraints cc = new CellConstraints();
    JLabel label = createI18NFormLabel("EMailHelper.PASSWORD"); //$NON-NLS-1$ //$NON-NLS-2$
    JPasswordField passField = createPasswordField(25);
    JCheckBox savePassword = createCheckBox(getResourceString("EMailHelper.SAVE_PASSWORD")); //$NON-NLS-1$

    builder.add(label, cc.xy(1, 1));
    builder.add(passField, cc.xy(3, 1));
    builder.add(savePassword, cc.xy(3, 3));
    JOptionPane.showConfirmDialog(topframe, builder.getPanel(), getResourceString("EMailHelper.PASSWORD_TITLE"), //$NON-NLS-1$
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);

    String passwordText = new String(passField.getPassword());
    if (savePassword.isSelected()) {
        AppPreferences appPrefs = AppPreferences.getRemote();
        if (StringUtils.isNotEmpty(passwordText)) {
            appPrefs.put("settings.email.password", Encryption.encrypt(passwordText)); //$NON-NLS-1$
        }
    }

    return passwordText;
}

From source file:net.sf.jabref.external.DroppedFileHandler.java

private boolean showLinkMoveCopyRenameDialog(String linkFileName, ExternalFileType fileType, BibEntry entry,
        BibDatabase database) {//from ww  w . ja  va 2s  .c  om

    String dialogTitle = Localization.lang("Link to file %0", linkFileName);
    List<String> dirs = panel.getBibDatabaseContext().getFileDirectory();
    int found = -1;
    for (int i = 0; i < dirs.size(); i++) {
        if (new File(dirs.get(i)).exists()) {
            found = i;
            break;
        }
    }
    if (found < 0) {
        destDirLabel.setText(Localization.lang("File directory is not set or does not exist!"));
        copyRadioButton.setEnabled(false);
        moveRadioButton.setEnabled(false);
        renameToTextBox.setEnabled(false);
        renameCheckBox.setEnabled(false);
        linkInPlace.setSelected(true);
    } else {
        destDirLabel.setText(Localization.lang("File directory is '%0':", dirs.get(found)));
        copyRadioButton.setEnabled(true);
        moveRadioButton.setEnabled(true);
        renameToTextBox.setEnabled(true);
        renameCheckBox.setEnabled(true);
    }

    ChangeListener cl = arg0 -> {
        renameCheckBox.setEnabled(!linkInPlace.isSelected());
        renameToTextBox.setEnabled(!linkInPlace.isSelected());
    };

    linkInPlace.setText(Localization.lang("Leave file in its current directory"));
    copyRadioButton.setText(Localization.lang("Copy file to file directory"));
    moveRadioButton.setText(Localization.lang("Move file to file directory"));
    renameCheckBox.setText(Localization.lang("Rename file to").concat(": "));

    // Determine which name to suggest:
    String targetName = FileUtil.createFileNameFromPattern(database, entry, Globals.journalAbbreviationLoader,
            Globals.prefs);

    renameToTextBox.setText(targetName.concat(".").concat(fileType.getExtension()));

    linkInPlace.setSelected(frame.prefs().getBoolean(DroppedFileHandler.DFH_LEAVE));
    copyRadioButton.setSelected(frame.prefs().getBoolean(DroppedFileHandler.DFH_COPY));
    moveRadioButton.setSelected(frame.prefs().getBoolean(DroppedFileHandler.DFH_MOVE));
    renameCheckBox.setSelected(frame.prefs().getBoolean(DroppedFileHandler.DFH_RENAME));

    linkInPlace.addChangeListener(cl);
    cl.stateChanged(new ChangeEvent(linkInPlace));

    try {
        Object[] messages = { Localization.lang("How would you like to link to '%0'?", linkFileName),
                optionsPanel };
        int reply = JOptionPane.showConfirmDialog(frame, messages, dialogTitle, JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        if (reply == JOptionPane.OK_OPTION) {
            // store user's choice
            frame.prefs().putBoolean(DroppedFileHandler.DFH_LEAVE, linkInPlace.isSelected());
            frame.prefs().putBoolean(DroppedFileHandler.DFH_COPY, copyRadioButton.isSelected());
            frame.prefs().putBoolean(DroppedFileHandler.DFH_MOVE, moveRadioButton.isSelected());
            frame.prefs().putBoolean(DroppedFileHandler.DFH_RENAME, renameCheckBox.isSelected());
            return true;
        } else {
            return false;
        }
    } finally {
        linkInPlace.removeChangeListener(cl);
    }
}

From source file:org.fhaes.jsea.JSEAFrame.java

/**
 * Initialize the menu/toolbar actions./*  w ww .ja v  a 2  s .c o  m*/
 */
private void initActions() {

    final JFrame glue = this;

    actionFileExit = new FHAESAction("Close", "close.png") { //$NON-NLS-1$

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            dispose();
        }
    };

    actionChartProperties = new FHAESAction("Chart properties", "properties.png") { //$NON-NLS-1$

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            ChartEditor editor = ChartEditorManager
                    .getChartEditor(jsea.getChartList().get(segmentComboBox.getSelectedIndex()).getChart());
            int result = JOptionPane.showConfirmDialog(glue, editor, "Properties", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE);
            if (result == JOptionPane.OK_OPTION) {
                editor.updateChart(jsea.getChartList().get(segmentComboBox.getSelectedIndex()).getChart());
            }
        }
    };

    actionReset = new FHAESAction("Reset", "filenew.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            Object[] options = { "Yes", "No", "Cancel" };
            int n = JOptionPane.showOptionDialog(glue, "Are you sure you want to start a new analysis?",
                    "Confirm", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,
                    options[2]);

            if (n == JOptionPane.YES_OPTION) {
                setToDefault();
            }
        }
    };

    actionRun = new FHAESAction("Run analysis", "run.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            runAnalysis();
        }
    };

    actionSaveAll = new FHAESAction("Save all results", "save_all.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            if (jsea == null)
                return;

            File file;
            JFileChooser fc;

            // Open file chooser in last folder if possible
            if (App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null) != null) {
                fc = new JFileChooser(App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null));
            } else {
                fc = new JFileChooser();
            }

            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

            // Show dialog and get specified file
            int returnVal = fc.showSaveDialog(glue);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                file = fc.getSelectedFile();
                App.prefs.setPref(PrefKey.PREF_LAST_EXPORT_FOLDER, file.getAbsolutePath());
            } else {
                return;
            }

            File f;
            try {
                f = new File(file.getAbsolutePath() + File.separator + "report.txt");
                saveReportTXT(f);

                f = new File(file.getAbsolutePath() + File.separator + "report.pdf");
                saveReportPDF(f);

                f = new File(file.getAbsolutePath() + File.separator + "chart.png");
                saveChartPNG(f);

                f = new File(file.getAbsolutePath() + File.separator + "chart.pdf");
                saveChartPDF(f);

                f = new File(file.getAbsolutePath() + File.separator + "data.xls");
                saveDataXLS(f);

                f = new File(file.getAbsolutePath());
                saveDataCSV(f);

            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };

    actionSaveData = new FHAESAction("Save data tables", "table.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            if (jsea == null)
                return;

            File file;
            JFileChooser fc;

            // Open file chooser in last folder if possible
            if (App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null) != null) {
                fc = new JFileChooser(App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null));
            } else {
                fc = new JFileChooser();
            }

            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

            // Show dialog and get specified file
            int returnVal = fc.showSaveDialog(glue);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                file = fc.getSelectedFile();
                App.prefs.setPref(PrefKey.PREF_LAST_EXPORT_FOLDER, file.getAbsolutePath());
            } else {
                return;
            }

            try {
                saveDataCSV(file);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };

    actionSaveReport = new FHAESAction("Save report", "report.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            if (jsea == null)
                return;

            File file;
            JFileChooser fc;

            // Open file chooser in last folder if possible
            if (App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null) != null) {
                fc = new JFileChooser(App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null));
            } else {
                fc = new JFileChooser();
            }

            // Set file filters
            fc.setAcceptAllFileFilterUsed(false);
            TXTFileFilter txtfilter = new TXTFileFilter();
            PDFFilter pdffilter = new PDFFilter();
            fc.addChoosableFileFilter(txtfilter);
            fc.addChoosableFileFilter(pdffilter);
            fc.setFileFilter(txtfilter);
            FileFilter chosenFilter;

            // Show dialog and get specified file
            int returnVal = fc.showSaveDialog(glue);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                file = fc.getSelectedFile();
                chosenFilter = fc.getFileFilter();
                App.prefs.setPref(PrefKey.PREF_LAST_EXPORT_FOLDER, file.getAbsolutePath());
            } else {
                return;
            }

            // Handle file type and extensions nicely
            if (FilenameUtils.getExtension(file.getAbsolutePath()).equals("")) {
                if (chosenFilter.equals(txtfilter)) {
                    file = new File(file.getAbsoluteFile() + ".txt");
                } else if (chosenFilter.equals(pdffilter)) {
                    file = new File(file.getAbsoluteFile() + ".pdf");
                }
            } else if (FilenameUtils.getExtension(file.getAbsolutePath()).toLowerCase().equals("txt")
                    && chosenFilter.equals("pdf")) {
                chosenFilter = txtfilter;
            } else if (FilenameUtils.getExtension(file.getAbsolutePath()).toLowerCase().equals("pdf")
                    && chosenFilter.equals("txt")) {
                chosenFilter = pdffilter;
            }

            // If file already exists confirm overwrite
            if (file.exists()) {
                // Check we have write access to this file
                if (!file.canWrite()) {
                    JOptionPane.showMessageDialog(glue, "You do not have write permission to this file",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }

                int n = JOptionPane.showConfirmDialog(glue,
                        "File: " + file.getName() + " already exists. " + "Would you like to overwrite it?",
                        "Overwrite file?", JOptionPane.YES_NO_OPTION);
                if (n != JOptionPane.YES_OPTION) {
                    return;
                }
            }

            // Do save
            try {

                if (chosenFilter.equals(txtfilter)) {
                    saveReportTXT(file);
                } else if (chosenFilter.equals(pdffilter)) {
                    saveReportPDF(file);
                } else {
                    log.error("No export file format chosen.  Shouldn't be able to get here!");
                }
            } catch (IOException e) {
                JOptionPane.showMessageDialog(glue, "Unable to save report.  Check log file.", "Warning",
                        JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
            }

        }
    };

    actionSaveChart = new FHAESAction("Save chart", "barchart.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            if (jsea == null)
                return;

            File file;
            JFileChooser fc;

            // Open file chooser in last folder if possible
            if (App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null) != null) {
                fc = new JFileChooser(App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null));
            } else {
                fc = new JFileChooser();
            }

            // Set file filters
            fc.setAcceptAllFileFilterUsed(false);
            PNGFilter pngfilter = new PNGFilter();
            PDFFilter pdffilter = new PDFFilter();
            fc.addChoosableFileFilter(pngfilter);
            fc.addChoosableFileFilter(pdffilter);
            fc.setFileFilter(pngfilter);
            FileFilter chosenFilter;

            // Show dialog and get specified file
            int returnVal = fc.showSaveDialog(glue);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                file = fc.getSelectedFile();
                chosenFilter = fc.getFileFilter();
                App.prefs.setPref(PrefKey.PREF_LAST_EXPORT_FOLDER, file.getAbsolutePath());
            } else {
                return;
            }

            // Handle file type and extensions nicely
            if (FilenameUtils.getExtension(file.getAbsolutePath()).equals("")) {
                if (chosenFilter.equals(pngfilter)) {
                    file = new File(file.getAbsoluteFile() + ".png");
                } else if (chosenFilter.equals(pdffilter)) {
                    file = new File(file.getAbsoluteFile() + ".pdf");
                }
            } else if (FilenameUtils.getExtension(file.getAbsolutePath()).toLowerCase().equals("png")
                    && chosenFilter.equals("pdf")) {
                chosenFilter = pngfilter;
            } else if (FilenameUtils.getExtension(file.getAbsolutePath()).toLowerCase().equals("pdf")
                    && chosenFilter.equals("png")) {
                chosenFilter = pdffilter;
            }

            // If file already exists confirm overwrite
            if (file.exists()) {
                // Check we have write access to this file
                if (!file.canWrite()) {
                    JOptionPane.showMessageDialog(glue, "You do not have write permission to this file",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }

                int n = JOptionPane.showConfirmDialog(glue,
                        "File: " + file.getName() + " already exists. " + "Would you like to overwrite it?",
                        "Overwrite file?", JOptionPane.YES_NO_OPTION);
                if (n != JOptionPane.YES_OPTION) {
                    return;
                }
            }

            // Do save
            try {

                if (chosenFilter.equals(pngfilter)) {
                    saveChartPNG(file);

                } else if (chosenFilter.equals(pdffilter)) {

                    saveChartPDF(file);
                } else {
                    log.error("No export file format chosen.  Shouldn't be able to get here!");
                }
            } catch (IOException e) {
                JOptionPane.showMessageDialog(glue, "Unable to save chart.  Check log file.", "Warning",
                        JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
            }

        }
    };

    actionCopy = new FHAESAction("Copy", "edit_copy.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            copyCurrentSelectionToClipboard();
        }
    };

    actionLagMap = new FHAESAction("LagMap", "lagmap22.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            launchLagMap();
        }
    };

}

From source file:net.sf.jabref.gui.journals.ManageJournalsPanel.java

private boolean readyToClose() {
    Path filePath;/*from w w w  . j  av  a  2s  .  c om*/
    if (newFile.isSelected()) {
        if (newNameTf.getText().isEmpty()) {
            if (tableModel.getRowCount() > 0) {
                JOptionPane.showMessageDialog(this,
                        Localization.lang("You must choose a filename to store journal abbreviations"),
                        Localization.lang("Store journal abbreviations"), JOptionPane.ERROR_MESSAGE);
                return false;
            } else {
                return true;
            }
        } else {
            filePath = Paths.get(newNameTf.getText());
            return !Files.exists(filePath) || (JOptionPane.showConfirmDialog(this,
                    Localization.lang("'%0' exists. Overwrite file?", filePath.getFileName().toString()),
                    Localization.lang("Store journal abbreviations"),
                    JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION);
        }
    }
    return true;
}

From source file:com._17od.upm.gui.DatabaseActions.java

/**
 * Prompt the user to enter a password//from www. j av  a2 s  .  com
 * @return The password entered by the user or null of this hit escape/cancel
 */
private char[] askUserForPassword(String message) {
    char[] password = null;

    final JPasswordField masterPassword = new JPasswordField("");
    JOptionPane pane = new JOptionPane(new Object[] { message, masterPassword }, JOptionPane.QUESTION_MESSAGE,
            JOptionPane.OK_CANCEL_OPTION);
    JDialog dialog = pane.createDialog(mainWindow, Translator.translate("masterPassword"));
    dialog.addWindowFocusListener(new WindowAdapter() {
        public void windowGainedFocus(WindowEvent e) {
            masterPassword.requestFocusInWindow();
        }
    });
    dialog.show();

    if (pane.getValue() != null && pane.getValue().equals(new Integer(JOptionPane.OK_OPTION))) {
        password = masterPassword.getPassword();
    }

    return password;
}

From source file:de.huxhorn.lilith.swing.preferences.PreferencesDialog.java

public void reinitializeDetailsViewFiles() {
    String dialogTitle = "Reinitialize details view files?";
    String message = "This resets all details view related files, all manual changes will be lost!\nReinitialize details view right now?";
    int result = JOptionPane.showConfirmDialog(this, message, dialogTitle, JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE);
    // TODO: add "Show in Finder/Explorer" button if running on Mac/Windows
    if (JOptionPane.OK_OPTION != result) {
        return;// www  . ja  v  a 2 s.  c om
    }

    applicationPreferences.initDetailsViewRoot(true);
}

From source file:io.heming.accountbook.ui.MainFrame.java

private void deleteRecord() {
    int selectedRow = table.getSelectedRow();
    if (selectedRow < 0) {
        JOptionPane.showMessageDialog(MainFrame.this, "", "",
                JOptionPane.ERROR_MESSAGE);
        return;//  w  ww .j  a v a2 s  . c o  m
    }
    Record record = model.getRecord(table.convertRowIndexToModel(selectedRow));
    System.out.println(record);
    if (JOptionPane.showConfirmDialog(MainFrame.this,
            String.format("??%d?", record.getId()), "",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) {
        try {
            recordFacade.delete(record);
            searchRecords();
        } catch (Exception e1) {
            e1.printStackTrace();
            JOptionPane.showMessageDialog(MainFrame.this, e1.getMessage(), "", JOptionPane.ERROR_MESSAGE);
        }
    }
}

From source file:ee.ioc.cs.vsle.editor.Editor.java

/**
 * Close application./*  w w w. j  a  v  a2 s  . com*/
 */
public void exitApplication() {
    int confirmed = JOptionPane.showConfirmDialog(this, "Exit Application?", Menu.EXIT,
            JOptionPane.OK_CANCEL_OPTION);
    switch (confirmed) {
    case JOptionPane.OK_OPTION:

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {

                int state = getExtendedState();

                if ((state & MAXIMIZED_BOTH) == MAXIMIZED_BOTH) {
                    // need to remember window's size in normal mode...looks
                    // ugly,
                    // any other ideas how to get normal size while staying
                    // maximized?
                    setExtendedState(NORMAL);
                }

                RuntimeProperties.setSchemeEditorWindowProps(getBounds(), state);

                RuntimeProperties.save();

                System.exit(0);
            }
        });

        break;
    case JOptionPane.CANCEL_OPTION:
        break;
    }
}

From source file:idontwant2see.IDontWant2See.java

private AbstractAction getActionInputTitle(final Program p, final String part) {
    return new AbstractAction(mLocalizer.msg("menu.userEntered", "User entered value")) {
        public void actionPerformed(final ActionEvent e) {
            final JCheckBox caseSensitive = new JCheckBox(mLocalizer.msg("caseSensitive", "case sensitive"));
            String title = p.getTitle();
            ArrayList<String> items = new ArrayList<String>();
            if (!StringUtils.isEmpty(part)) {
                String shortTitle = title.trim().substring(0, title.length() - part.length()).trim();
                shortTitle = StringUtils.removeEnd(shortTitle, "-").trim();
                shortTitle = StringUtils.removeEnd(shortTitle, "(").trim();
                items.add(shortTitle + "*");
            }/* w  ww  .  j  a v  a2s  .  co  m*/
            int index = title.indexOf(" - ");
            if (index > 0) {
                items.add(title.substring(0, index).trim() + "*");
            }
            items.add(title);
            index = title.lastIndexOf(':');
            if (index > 0) {
                items.add(title.substring(0, index).trim() + "*");
            }
            final JComboBox input = new JComboBox(items.toArray(new String[items.size()]));
            input.setEditable(true);

            input.addAncestorListener(new AncestorListener() {
                public void ancestorAdded(final AncestorEvent event) {
                    event.getComponent().requestFocus();
                }

                public void ancestorMoved(final AncestorEvent event) {
                }

                public void ancestorRemoved(final AncestorEvent event) {
                }
            });

            if (JOptionPane.showConfirmDialog(UiUtilities.getLastModalChildOf(getParentFrame()),
                    new Object[] {
                            mLocalizer.msg("exclusionText",
                                    "What should be excluded? (You can use the wildcard *)"),
                            input, caseSensitive },
                    mLocalizer.msg("exclusionTitle", "Exclusion value entering"),
                    JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
                String test = "";

                String result = (String) input.getSelectedItem();
                if (result != null) {
                    test = result.replaceAll("\\*+", "\\*").trim();

                    if (test.length() >= 0 && !test.equals("*")) {
                        mSettings.getSearchList()
                                .add(new IDontWant2SeeListEntry(result, caseSensitive.isSelected()));
                        mSettings.setLastEnteredExclusionString(result);
                        updateFilter(!mSettings.isSwitchToMyFilter());
                    }
                }

                if (test.trim().length() <= 1) {
                    JOptionPane.showMessageDialog(UiUtilities.getLastModalChildOf(getParentFrame()),
                            mLocalizer.msg("notValid", "The entered text is not valid."),
                            Localizer.getLocalization(Localizer.I18N_ERROR), JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    };
}

From source file:gui.DownloadPanel.java

public void actionClear() {
    int action = JOptionPane.showConfirmDialog(parent, "Do you realy want to delete selected file?",
            "Confirm delete", JOptionPane.OK_CANCEL_OPTION);
    if (action == JOptionPane.OK_OPTION) {
        if (selectedDownload == null)
            return;
        //     download download = selectedDownloadDialog.getDownload();

        clearing = true;//from w w w . j a  v  a 2 s. co m
        downloadsTableModel.clearDownload(selectedDownload);
        if (downloadList.contains(selectedDownload))
            downloadList.remove(selectedDownload);
        clearing = false;

        //    selectedDownloadDialog = null;
        DownloadDialog downloadDialog = getDownloadDialogByDownload(selectedDownload);
        downloadDialogs.remove(downloadDialog);
        downloadDialog.dispose();
        downloadDialog.removeDownloadInfoListener(this);
        downloadDialog = null;

        try {
            databaseController.delete(selectedDownload.getId());
        } catch (SQLException e) {
            //      e.printStackTrace();
        }

        try {
            FileUtils.forceDelete(new File(selectedDownload.getDownloadRangePath() + File.separator
                    + selectedDownload.getDownloadName())); // todo must again
        } catch (IOException e) {
            //      e.printStackTrace();
        }

        selectedDownload = null;
        tableSelectionChanged();
    }
}