Example usage for javax.swing JFileChooser setFileFilter

List of usage examples for javax.swing JFileChooser setFileFilter

Introduction

In this page you can find the example usage for javax.swing JFileChooser setFileFilter.

Prototype

@BeanProperty(preferred = true, description = "Sets the File Filter used to filter out files of type.")
public void setFileFilter(FileFilter filter) 

Source Link

Document

Sets the current file filter.

Usage

From source file:gov.nij.er.ui.EntityResolutionDemo.java

private void saveParameters() {
    JFileChooser fc = new JFileChooser();
    fc.setFileFilter(new SerializedParameterFileFilter());
    int returnVal = fc.showSaveDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        try {//  w  ww. j a v  a2 s  .co  m
            saveParameters(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:gov.nij.er.ui.EntityResolutionDemo.java

private void loadParameters() {
    JFileChooser fc = new JFileChooser();
    fc.setFileFilter(new SerializedParameterFileFilter());
    int returnVal = fc.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        try {//from  w w w .  j  av  a 2 s .c om
            loadParameters(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:table.TablePanel.java

public String doSaveAs(File f) throws IOException {
    JFileChooser fileChooser = new JFileChooser();
    FileNameExtensionFilter filter = new FileNameExtensionFilter("PNG Image Files", "png");
    fileChooser.addChoosableFileFilter(filter);
    fileChooser.setFileFilter(filter);
    String filename = "";
    int option = fileChooser.showSaveDialog(this.parent);
    if (option == JFileChooser.APPROVE_OPTION) {
        filename = fileChooser.getSelectedFile().getPath();
        if (!filename.endsWith(".png")) {
            filename = filename + ".png";
        }//from www  .  j a  v  a2  s . com
        saveTableAsPNG(new File(filename), this.table, parent.getWidth(), parent.getHeight());
    }
    return filename;
}

From source file:com.josue.tileset.editor.Editor.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    JFileChooser fileDialog = new JFileChooser();
    fileDialog.setFileFilter(new FileNameExtensionFilter("Image file", "png"));
    fileDialog.showOpenDialog(null);//  w  w  w . j  a  v a2 s .c  om
    inputFile = fileDialog.getSelectedFile();
    if (inputFile != null) {
        loadFile(inputFile);
    }
}

From source file:com.litt.core.security.license.gui.ValidatePanel.java

/**
 * Create the panel.//from   w ww .  j  a v  a2  s.  c  o m
 */
public ValidatePanel() {
    GridBagLayout gbl_validatePanel = new GridBagLayout();
    gbl_validatePanel.columnWidths = new int[] { 0, 0, 0 };
    gbl_validatePanel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    gbl_validatePanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gbl_validatePanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            Double.MIN_VALUE };
    this.setLayout(gbl_validatePanel);

    JLabel label_10 = new JLabel("");
    GridBagConstraints gbc_label_10 = new GridBagConstraints();
    gbc_label_10.insets = new Insets(0, 0, 5, 5);
    gbc_label_10.anchor = GridBagConstraints.EAST;
    gbc_label_10.gridx = 0;
    gbc_label_10.gridy = 0;
    this.add(label_10, gbc_label_10);

    field_pubKeyFilePath = new JTextField();
    field_pubKeyFilePath.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            JFileChooser fileChooser = new JFileChooser();
            //fileChooser.setVisible(true);
            LicenseFileFilter fileFilter = new LicenseFileFilter(new String[] { "key" });
            fileChooser.setFileFilter(fileFilter);
            fileChooser.addChoosableFileFilter(fileFilter);
            fileChooser.showOpenDialog(e.getComponent());
            File pubKeyFile = fileChooser.getSelectedFile();

            field_pubKeyFilePath.setText(pubKeyFile.getAbsolutePath());

        }
    });
    GridBagConstraints gbc_field_pubKeyFilePath = new GridBagConstraints();
    gbc_field_pubKeyFilePath.insets = new Insets(0, 0, 5, 0);
    gbc_field_pubKeyFilePath.fill = GridBagConstraints.HORIZONTAL;
    gbc_field_pubKeyFilePath.gridx = 1;
    gbc_field_pubKeyFilePath.gridy = 0;
    this.add(field_pubKeyFilePath, gbc_field_pubKeyFilePath);
    field_pubKeyFilePath.setColumns(10);

    JLabel label_19 = new JLabel("?");
    GridBagConstraints gbc_label_19 = new GridBagConstraints();
    gbc_label_19.anchor = GridBagConstraints.EAST;
    gbc_label_19.insets = new Insets(0, 0, 5, 5);
    gbc_label_19.gridx = 0;
    gbc_label_19.gridy = 1;
    this.add(label_19, gbc_label_19);

    field_licenseFilePath = new JTextField();
    field_licenseFilePath.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            JFileChooser fileChooser = new JFileChooser();
            //fileChooser.setVisible(true);
            LicenseFileFilter fileFilter = new LicenseFileFilter(new String[] { "xml" });
            fileChooser.setFileFilter(fileFilter);
            fileChooser.addChoosableFileFilter(fileFilter);
            fileChooser.showOpenDialog(e.getComponent());
            File licenseFile = fileChooser.getSelectedFile();

            field_licenseFilePath.setText(licenseFile.getAbsolutePath());
        }
    });
    GridBagConstraints gbc_textField1 = new GridBagConstraints();
    gbc_textField1.insets = new Insets(0, 0, 5, 0);
    gbc_textField1.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField1.gridx = 1;
    gbc_textField1.gridy = 1;
    this.add(field_licenseFilePath, gbc_textField1);
    field_licenseFilePath.setColumns(10);

    JLabel lblid = new JLabel("?ID");
    lblid.setHorizontalAlignment(SwingConstants.CENTER);
    GridBagConstraints gbc_lblid = new GridBagConstraints();
    gbc_lblid.insets = new Insets(0, 0, 5, 5);
    gbc_lblid.gridx = 0;
    gbc_lblid.gridy = 2;
    this.add(lblid, gbc_lblid);

    label_licenseId = new JLabel("");
    label_licenseId.setHorizontalAlignment(SwingConstants.CENTER);
    GridBagConstraints gbc_label_licenseId = new GridBagConstraints();
    gbc_label_licenseId.insets = new Insets(0, 0, 5, 0);
    gbc_label_licenseId.gridx = 1;
    gbc_label_licenseId.gridy = 2;
    this.add(label_licenseId, gbc_label_licenseId);

    JLabel label_12 = new JLabel("?");
    GridBagConstraints gbc_label_12 = new GridBagConstraints();
    gbc_label_12.insets = new Insets(0, 0, 5, 5);
    gbc_label_12.gridx = 0;
    gbc_label_12.gridy = 3;
    this.add(label_12, gbc_label_12);

    label_licenseType = new JLabel("");
    GridBagConstraints gbc_label_licenseType = new GridBagConstraints();
    gbc_label_licenseType.insets = new Insets(0, 0, 5, 0);
    gbc_label_licenseType.gridx = 1;
    gbc_label_licenseType.gridy = 3;
    this.add(label_licenseType, gbc_label_licenseType);

    JLabel label_13 = new JLabel("???");
    GridBagConstraints gbc_label_13 = new GridBagConstraints();
    gbc_label_13.insets = new Insets(0, 0, 5, 5);
    gbc_label_13.gridx = 0;
    gbc_label_13.gridy = 4;
    this.add(label_13, gbc_label_13);

    label_productName = new JLabel("");
    GridBagConstraints gbc_label_productName = new GridBagConstraints();
    gbc_label_productName.insets = new Insets(0, 0, 5, 0);
    gbc_label_productName.gridx = 1;
    gbc_label_productName.gridy = 4;
    this.add(label_productName, gbc_label_productName);

    JLabel label_14 = new JLabel("???");
    GridBagConstraints gbc_label_14 = new GridBagConstraints();
    gbc_label_14.insets = new Insets(0, 0, 5, 5);
    gbc_label_14.gridx = 0;
    gbc_label_14.gridy = 5;
    this.add(label_14, gbc_label_14);

    label_companyName = new JLabel("");
    GridBagConstraints gbc_label_companyName = new GridBagConstraints();
    gbc_label_companyName.insets = new Insets(0, 0, 5, 0);
    gbc_label_companyName.gridx = 1;
    gbc_label_companyName.gridy = 5;
    this.add(label_companyName, gbc_label_companyName);

    JLabel label_15 = new JLabel("??");
    GridBagConstraints gbc_label_15 = new GridBagConstraints();
    gbc_label_15.insets = new Insets(0, 0, 5, 5);
    gbc_label_15.gridx = 0;
    gbc_label_15.gridy = 6;
    this.add(label_15, gbc_label_15);

    label_customerName = new JLabel("");
    GridBagConstraints gbc_label_customerName = new GridBagConstraints();
    gbc_label_customerName.insets = new Insets(0, 0, 5, 0);
    gbc_label_customerName.gridx = 1;
    gbc_label_customerName.gridy = 6;
    this.add(label_customerName, gbc_label_customerName);

    JLabel label_16 = new JLabel("");
    GridBagConstraints gbc_label_16 = new GridBagConstraints();
    gbc_label_16.insets = new Insets(0, 0, 5, 5);
    gbc_label_16.gridx = 0;
    gbc_label_16.gridy = 7;
    this.add(label_16, gbc_label_16);

    label_version = new JLabel("");
    GridBagConstraints gbc_label_version = new GridBagConstraints();
    gbc_label_version.insets = new Insets(0, 0, 5, 0);
    gbc_label_version.gridx = 1;
    gbc_label_version.gridy = 7;
    this.add(label_version, gbc_label_version);

    JLabel label_11 = new JLabel("");
    GridBagConstraints gbc_label_11 = new GridBagConstraints();
    gbc_label_11.insets = new Insets(0, 0, 5, 5);
    gbc_label_11.gridx = 0;
    gbc_label_11.gridy = 8;
    this.add(label_11, gbc_label_11);

    label_createDate = new JLabel("");
    GridBagConstraints gbc_label_createDate = new GridBagConstraints();
    gbc_label_createDate.insets = new Insets(0, 0, 5, 0);
    gbc_label_createDate.gridx = 1;
    gbc_label_createDate.gridy = 8;
    this.add(label_createDate, gbc_label_createDate);

    JLabel label_17 = new JLabel("");
    GridBagConstraints gbc_label_17 = new GridBagConstraints();
    gbc_label_17.insets = new Insets(0, 0, 5, 5);
    gbc_label_17.gridx = 0;
    gbc_label_17.gridy = 9;
    this.add(label_17, gbc_label_17);

    label_expiredDate = new JLabel("");
    GridBagConstraints gbc_label_expiredDate = new GridBagConstraints();
    gbc_label_expiredDate.insets = new Insets(0, 0, 5, 0);
    gbc_label_expiredDate.gridx = 1;
    gbc_label_expiredDate.gridy = 9;
    this.add(label_expiredDate, gbc_label_expiredDate);

    JButton button_2 = new JButton("");
    button_2.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

            String licenseFilePath = Utility.trimNull(field_licenseFilePath.getText());
            String pubKeyFilePath = Utility.trimNull(field_pubKeyFilePath.getText());
            if (Utility.isEmpty(licenseFilePath)) {
                JOptionPane.showMessageDialog(e.getComponent(), "?!");
                return;
            }
            if (Utility.isEmpty(pubKeyFilePath)) {
                JOptionPane.showMessageDialog(e.getComponent(), "!");
                return;
            }
            File licenseFile = new File(licenseFilePath);
            try {
                XMLConfiguration config = new XMLConfiguration(licenseFile);
                config.setAutoSave(true);

                label_licenseId.setText(config.getString(("licenseId")));
                label_licenseType.setText(config.getString("licenseType"));
                label_productName.setText(config.getString("productName"));
                label_companyName.setText(config.getString("companyName"));
                label_customerName.setText(config.getString("customerName"));
                label_version.setText(config.getString("version"));
                label_createDate.setText(config.getString("createDate"));
                label_expiredDate.setText(config.getString("expiredDate"));

            } catch (Exception e1) {
                // TODO Auto-generated catch block
                JOptionPane.showMessageDialog(e.getComponent(), e1.getMessage());
            }

            try {
                LicenseManager.validateLicense(licenseFile.getAbsolutePath(), pubKeyFilePath);
                JOptionPane.showMessageDialog(e.getComponent(), "?");
            } catch (LicenseException e1) {
                // TODO Auto-generated catch block
                JOptionPane.showMessageDialog(e.getComponent(), e1.getMessage());
            }

        }
    });
    GridBagConstraints gbc_button_2 = new GridBagConstraints();
    gbc_button_2.gridx = 1;
    gbc_button_2.gridy = 10;
    this.add(button_2, gbc_button_2);
}

From source file:com.josue.tileset.editor.Editor.java

private void exportBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportBtnActionPerformed

    JFileChooser fileDialog = new JFileChooser();
    fileDialog.setFileFilter(new FileNameExtensionFilter("Json file", "json"));
    String outputFileName = inputFile.getAbsolutePath().split("\\.")[0] + ".json";
    fileDialog.setSelectedFile(new File(outputFileName));
    if (fileDialog.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {

        File file = fileDialog.getSelectedFile();
        ObjectMapper mapper = new ObjectMapper();
        mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE);
        mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
        try {/* www.j av  a  2s.  c  om*/
            mapper.writeValue(file, loadedTiles);
        } catch (IOException ex) {
            Logger.getLogger(Editor.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}

From source file:gov.nij.er.ui.EntityResolutionDemo.java

private void handleLoadExcelDataCommand() {
    JFileChooser fc = new JFileChooser();
    fc.setFileFilter(new FileFilter() {
        @Override//from  www.j a  v a 2s . c om
        public boolean accept(File f) {
            String name = f.getName();
            return f.isDirectory() || name.endsWith(".xls") || name.endsWith(".xlsx");
        }

        @Override
        public String getDescription() {
            return "Excel Workbooks (*.xls, *.xlsx)";
        }
    });
    int returnVal = fc.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        final File file = fc.getSelectedFile();
        try {
            new UIBlockingTask(new RunnableTask() {
                public void run() throws Exception {
                    loadExcelData(file);
                }
            }).execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:au.org.ala.delta.editor.ui.ImageDetailsPanel.java

private File getMediaFile(FileFilter filter) {
    String imagePath = _dataSet.getImagePath();
    JFileChooser chooser = new JFileChooser(imagePath);
    chooser.setFileFilter(filter);

    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        File imageFile = chooser.getSelectedFile();

        ImageSettings settings = _dataSet.getImageSettings();
        if (settings.isOnResourcePath(imageFile)) {

            String name = imageFile.getName();
            boolean exists = false;

            if (_selectedImage != null) {
                List<ImageOverlay> existingSounds = _selectedImage.getSounds();
                for (ImageOverlay sound : existingSounds) {
                    if (name.equals(sound.overlayText)) {
                        exists = true;//from  w w  w . j  a  v a2s.c om
                        break;
                    }
                }
            }
            if (exists) {
                int result = _messageHelper.confirmDuplicateFileName();
                if (result == JOptionPane.YES_OPTION) {
                    imageFile = new File(imageFile.getAbsolutePath());
                } else if (result == JOptionPane.NO_OPTION) {
                    return getMediaFile(filter);
                } else {
                    imageFile = null;
                }
            } else {
                // Turn the file into a relative one.
                imageFile = new File(name);
            }
        } else {
            // Ask about it or copy it to the image path.
            int result = _messageHelper.confirmNotOnImagePath();
            if (result == JOptionPane.YES_OPTION) {
                imageFile = new File(imageFile.getAbsolutePath());
            } else if (result == JOptionPane.NO_OPTION) {
                return getMediaFile(filter);
            } else {
                imageFile = null;
            }
        }

        return imageFile;
    }

    return null;
}

From source file:io.github.jeremgamer.editor.panels.IconFrame.java

public IconFrame(JFrame parent) {
    this.setModal(true);
    this.setResizable(false);
    ArrayList<BufferedImage> icons = new ArrayList<BufferedImage>();
    try {//from   ww  w  . j a v  a  2  s. c  o m
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon16.png")));
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon32.png")));
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon64.png")));
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon128.png")));
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    this.setIconImages((List<? extends Image>) icons);
    this.setTitle("Icnes");

    this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    JPanel content = new JPanel();
    content.setLayout(new BoxLayout(content, BoxLayout.LINE_AXIS));
    content.setBorder(BorderFactory.createTitledBorder(""));

    try {
        remove128.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
        remove64.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
        remove32.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
        remove16.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    browse128.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "128.png");
                try {
                    x128.repaint();
                    x128.getGraphics().drawImage(ImageIO.read(new File(path)), 0 + 10, 0 + 20, 128, 128, null);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    });
    remove128.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File("projects/" + Editor.getProjectName() + "/128.png");
            file.delete();
            x128.repaint();
        }
    });
    browse64.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "64.png");
                try {
                    x64.repaint();
                    x64.getGraphics().drawImage(ImageIO.read(new File(path)), 32 + 10, 32 + 20, 64, 64, null);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    });
    remove64.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File("projects/" + Editor.getProjectName() + "/64.png");
            file.delete();
            x64.repaint();
        }
    });
    browse32.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "32.png");
                try {
                    x32.repaint();
                    x32.getGraphics().drawImage(ImageIO.read(new File(path)), 48 + 10, 48 + 20, 32, 32, null);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    });
    remove32.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File("projects/" + Editor.getProjectName() + "/32.png");
            file.delete();
            x32.repaint();
        }
    });
    browse16.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "16.png");
                try {
                    x16.repaint();
                    x16.getGraphics().drawImage(ImageIO.read(new File(path)), 56 + 10, 56 + 20, 16, 16, null);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    });
    remove16.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File("projects/" + Editor.getProjectName() + "/16.png");
            file.delete();
            x16.repaint();
        }
    });

    content.add(x128);
    content.add(x64);
    content.add(x32);
    content.add(x16);
    this.setContentPane(content);
    this.pack();
    this.setLocationRelativeTo(parent);
    this.setVisible(true);
}

From source file:de.ep3.ftpc.controller.portal.CrawlerDownloadController.java

@Override
public void mouseClicked(MouseEvent e) {
    CrawlerResultsItem.PreviewPanel previewPanel = (CrawlerResultsItem.PreviewPanel) e.getSource();
    CrawlerResult crawlerResult = previewPanel.getCrawlerResult();
    CrawlerFile crawlerFile = crawlerResult.getFile();

    FTPClient ftpClient = crawlerResult.getFtpClient();

    if (ftpClient.isConnected()) {
        JOptionPane.showMessageDialog(portalFrame, i18n.translate("crawlerDownloadWhileConnected"), null,
                JOptionPane.ERROR_MESSAGE);
        return;/*from  w  ww  .ja  va 2 s . c o  m*/
    }

    String fileExtension = crawlerFile.getExtension();

    JFileChooser chooser = new JFileChooser();
    FileNameExtensionFilter chooserFilter = new FileNameExtensionFilter(
            i18n.translate("fileType", fileExtension.toUpperCase()), crawlerFile.getExtension());

    chooser.setApproveButtonText(i18n.translate("buttonSave"));
    chooser.setDialogTitle(i18n.translate("fileDownloadTo"));
    chooser.setDialogType(JFileChooser.SAVE_DIALOG);
    chooser.setFileFilter(chooserFilter);
    chooser.setSelectedFile(new File(crawlerFile.getName()));

    int selection = chooser.showSaveDialog(portalFrame);

    if (selection == JFileChooser.APPROVE_OPTION) {
        File fileToSave = chooser.getSelectedFile();

        Server relatedServer = crawlerResult.getServer();

        try {
            ftpClient.connect(relatedServer.need("server.ip"),
                    Integer.parseInt(relatedServer.need("server.port")));

            int replyCode = ftpClient.getReplyCode();

            if (!FTPReply.isPositiveCompletion(replyCode)) {
                throw new IOException(i18n.translate("crawlerServerRefused"));
            }

            if (relatedServer.has("user.name")) {
                String userName = relatedServer.get("user.name");
                String userPassword = "";

                if (relatedServer.hasTemporary("user.password")) {
                    userPassword = relatedServer.getTemporary("user.password");
                }

                boolean loggedIn = ftpClient.login(userName, userPassword);

                if (!loggedIn) {
                    throw new IOException(i18n.translate("crawlerServerAuthFail"));
                }
            }

            ftpClient.setFileType(FTP.BINARY_FILE_TYPE);

            /* Download file */

            InputStream is = ftpClient.retrieveFileStream(crawlerFile.getFullName());

            if (is != null) {

                byte[] rawFile = new byte[(int) crawlerFile.getSize()];

                int i = 0;

                while (true) {
                    int b = is.read();

                    if (b == -1) {
                        break;
                    }

                    rawFile[i] = (byte) b;
                    i++;

                    /* Occasionally update the download progress */

                    if (i % 1024 == 0) {
                        int progress = Math.round((((float) i) / crawlerFile.getSize()) * 100);

                        status.add(i18n.translate("crawlerDownloadProgress", progress));
                    }
                }

                is.close();
                is = null;

                if (!ftpClient.completePendingCommand()) {
                    throw new IOException();
                }

                Files.write(fileToSave.toPath(), rawFile);
            }

            /* Logout and disconnect */

            ftpClient.logout();

            tryDisconnect(ftpClient);

            status.add(i18n.translate("crawlerDownloadDone"));
        } catch (IOException ex) {
            tryDisconnect(ftpClient);

            JOptionPane.showMessageDialog(portalFrame, i18n.translate("crawlerDownloadFailed", ex.getMessage()),
                    null, JOptionPane.ERROR_MESSAGE);
        }
    }
}