Exemplo n.º 1
0
    public void actionPerformed(ActionEvent e) {
      if (readOnly) {
        return;
      }
      JFileChooser fc = getFileChooser();
      File currentDirectory = fc.getCurrentDirectory();

      if (!currentDirectory.exists()) {
        JOptionPane.showMessageDialog(
            fc,
            newFolderParentDoesntExistText,
            newFolderParentDoesntExistTitleText,
            JOptionPane.WARNING_MESSAGE);
        return;
      }

      File newFolder;
      try {
        newFolder = fc.getFileSystemView().createNewFolder(currentDirectory);
        if (fc.isMultiSelectionEnabled()) {
          fc.setSelectedFiles(new File[] {newFolder});
        } else {
          fc.setSelectedFile(newFolder);
        }
      } catch (IOException exc) {
        JOptionPane.showMessageDialog(
            fc,
            newFolderErrorText + newFolderErrorSeparator + exc,
            newFolderErrorText,
            JOptionPane.ERROR_MESSAGE);
        return;
      }

      fc.rescanCurrentDirectory();
    }
Exemplo n.º 2
0
  private void findPresentation() {
    JFileChooser fileChooser = new JFileChooser();
    if (lastDirectory_ != null) fileChooser.setCurrentDirectory(lastDirectory_);
    // if (imc.lecturnity.converter.ConverterWizard.USE_CUSTOM_COLORS)
    if (USE_CUSTOM_COLORS) fileChooser.setBackground(Wizard.BG_COLOR);
    LecturnityFileFilter lff = new LecturnityFileFilter();
    fileChooser.addChoosableFileFilter(lff);
    LpdFileFilter lpf = new LpdFileFilter();
    fileChooser.addChoosableFileFilter(lpf);
    EPresentationFileFilter eff = new EPresentationFileFilter();
    fileChooser.addChoosableFileFilter(eff);
    AofFileFilter aff = new AofFileFilter();
    fileChooser.addChoosableFileFilter(aff);
    fileChooser.addChoosableFileFilter(fileChooser.getAcceptAllFileFilter());
    fileChooser.setFileFilter(lff);

    Dimension fcSize = fileChooser.getPreferredSize();
    fileChooser.setPreferredSize(new Dimension(fcSize.width + 100, fcSize.height + 50));

    int action = fileChooser.showOpenDialog(this);

    lastDirectory_ = fileChooser.getCurrentDirectory();

    if (action == fileChooser.APPROVE_OPTION) {
      File selectedFile = fileChooser.getSelectedFile();
      presentationFileField_.setText(selectedFile.getAbsolutePath());
    }
  }
 public void actionPerformed(ActionEvent ae) {
   String cmd = ae.getActionCommand();
   if (JOkCancelPanel.OK.equals(cmd)) {
     // update evaluator
     evaluator.name = tfName.getText();
     evaluator.type = (byte) cbType.getSelectedIndex();
     evaluator.ignoreDiagonals = cbDiagonals.isSelected();
     evaluator.investments = (byte) cbInvestment.getSelectedIndex();
     evaluator.orgFile = orgFile;
     setVisible(false);
   } else if (JOkCancelPanel.CANCEL.equals(cmd)) {
     // don't update evaluator
     setVisible(false);
   } else if (CMD_CHOOSE_FILE.equals(cmd)) {
     // get a file dialog
     JFrame f = new JFrame();
     JFileChooser jfc = Application.getFileChooser();
     int res = jfc.showOpenDialog(f);
     Application.setWorkingDirectory(jfc.getCurrentDirectory());
     if (res == JFileChooser.CANCEL_OPTION) {
       return;
     }
     orgFile = jfc.getSelectedFile();
     lOrgFileName.setText("File: " + orgFile.getName());
   }
 }
 private void openFile() {
   // opens a single file chooser (can select multiple), does not traverse folders.
   this.copyList = new ArrayList();
   final JFileChooser fc = new JFileChooser(currentPath);
   fc.setMultiSelectionEnabled(true);
   fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
   FileNameExtensionFilter filterhtml = new FileNameExtensionFilter("HTML File (.html)", "html");
   fc.addChoosableFileFilter(filterhtml);
   fc.setFileFilter(filterhtml);
   int result = fc.showOpenDialog(FrontEnd.this);
   dir = fc.getCurrentDirectory();
   dirImp = dir.toString();
   switch (result) {
     case JFileChooser.APPROVE_OPTION:
       for (File file1 : fc.getSelectedFiles()) {
         fileImp = file1.toString();
         boolean exists = false;
         for (int i = 0; i < table.getRowCount(); i++) {
           dir = fc.getCurrentDirectory();
           dirImp = dir.toString();
           String copyC = dtm.getValueAt(i, 0).toString();
           if (duplC.isSelected()) {
             if (fileImp.endsWith(copyC)) {
               exists = true;
               break;
             }
           }
         }
         if (!exists) {
           addRow();
           dtm.setValueAt(fileImp.substring(67), curRow, 0);
           dtm.setValueAt(dirImp.substring(67), curRow, 1);
           curRow++;
           if (headC == 1) {
             if (fileImp.substring(67).endsWith(dirImp.substring(67) + ".html")) {
               curRow--;
               dtm.removeRow(curRow);
             }
           }
         }
       }
     case JFileChooser.CANCEL_OPTION:
       break;
   }
 }
  public SelectorDeArchivos(OPERACION operacion) {
    _archivo = null;
    JFileChooser selector = new JFileChooser();
    int opcion;
    if (operacion == OPERACION.CARGA) {
      selector.setFileFilter(new FiltroArchivos());
      opcion = selector.showOpenDialog(new JFrame());
    } else opcion = selector.showSaveDialog(new JFrame());

    if (opcion == JFileChooser.APPROVE_OPTION)
      _archivo =
          selector.getCurrentDirectory().toString() + "/" + selector.getSelectedFile().getName();
  }
  /** Validates content of file cache. */
  public void validateFileCache() {
    File currentDirectory = filechooser.getCurrentDirectory();
    if (currentDirectory == null) {
      return;
    }
    if (filesLoader != null) {
      filesLoader.loadThread.interrupt();
      filesLoader.cancelRunnables();
    }

    setBusy(true, ++fetchID);

    filesLoader = new FilesLoader(currentDirectory, fetchID);
  }
 public void actionPerformed(ActionEvent e) {
   int x = jfc.showSaveDialog(null);
   // int x=jfc.showOpenDialog(null);
   if (x == JFileChooser.APPROVE_OPTION) {
     File f = jfc.getSelectedFile();
     System.out.println(f.getPath());
     System.out.println(jfc.getName(f));
     File f1 = jfc.getCurrentDirectory();
     System.out.println(jfc.getName(f1));
   }
   if (x == JFileChooser.CANCEL_OPTION) {
     System.out.println("cancle");
   }
 }
Exemplo n.º 8
0
  /**
   * Checks whether the given window is either a FileDialog, or contains a JFileChooser component.
   * If so, its current directory is restored from the given properties.
   *
   * @param aNamespace the name space to use;
   * @param aProperties the properties to get the directory from;
   * @param aWindow the window to check for.
   */
  private static void saveFileDialogState(final Preferences aProperties, final Window aWindow) {
    final String propKey = "lastDirectory";

    if (aWindow instanceof FileDialog) {
      final String dir = ((FileDialog) aWindow).getDirectory();
      if (dir != null) {
        aProperties.put(propKey, dir);
      }
    } else if (aWindow instanceof JDialog) {
      final Container contentPane = ((JDialog) aWindow).getContentPane();
      final JFileChooser fileChooser =
          (JFileChooser) findComponent(contentPane, JFileChooser.class);
      if (fileChooser != null) {
        final File dir = fileChooser.getCurrentDirectory();
        if (dir != null) {
          aProperties.put(propKey, dir.getAbsolutePath());
        }
      }
    }
  }
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == create) {
     boolean flag = false;
     for (JCheckBox cur : checks) if (cur.isSelected()) flag = true;
     if (flag) {
       File path = chooser.getCurrentDirectory();
       ArrayList<String> cath_selected = new ArrayList<String>();
       for (JCheckBox cur : checks)
         if (cur.isSelected())
           if (cur.getText().compareTo("выбрать все...") != 0) cath_selected.add(cur.getText());
       String mode = new String();
       if (semester_combo.getSelectedItem().toString().compareTo("летний") == 0) mode = "summer";
       else mode = "winter";
       Dispatcher.createEducAssignment(cath_selected, path, mode);
       this.dispose();
     } else
       JOptionPane.showMessageDialog(
           null, "ƒл¤ формировани¤ учебных поручений необходимо определить кафедры.");
   }
   if (e.getSource() == cancel) this.dispose();
 }
Exemplo n.º 10
0
  private void generateFile() {
    int res = fileChooser.showSaveDialog(this);
    if (res != JFileChooser.APPROVE_OPTION) return;
    fileChooser.getCurrentDirectory();
    File dir = fileChooser.getSelectedFile();

    String source = wordListArea.getText();
    String[] lines = source.split("\n");
    ArrayList<String> list = new ArrayList<String>(lines.length);
    for (String line1 : lines) {
      String line = line1.trim();
      if (line.length() > 0) {
        list.add(line);
      }
    }
    String titlePre = "wordlist";
    String titleInput = titleField.getText().trim();
    if (titleInput.length() > 0) titlePre = titleInput;
    boolean split = splitLinesCheckBox.isSelected();
    int splitNum = (Integer) splitNumSpinner.getValue();

    try {
      if (!split || list.size() < splitNum) {
        File file = new File(dir, titlePre + ".xml");
        PrintWriter writer = new PrintWriter(file, "UTF-8");
        writer.println(format(titlePre, list));
        writer.close();
      } else {
        for (int i = 0; i < list.size() / splitNum; i++) {
          String title = titlePre + "_" + (i + 1);
          File file = new File(dir, title + ".xml");
          PrintWriter writer = new PrintWriter(file, "UTF-8");
          writer.println(format(title, list.subList(i * splitNum, (i + 1) * splitNum - 1)));
          writer.close();
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
 private void outputToExcel(ActionEvent e) {
   JFileChooser chooser =
       new JFileChooser() {
         @Override
         protected JDialog createDialog(Component parent) throws HeadlessException {
           JDialog dialog = super.createDialog(parent);
           dialog.setTitle("Export the content to an Excel file");
           return dialog;
         }
       };
   chooser.setCurrentDirectory(new File(_lastDirectory));
   int result = chooser.showDialog(((JButton) e.getSource()).getTopLevelAncestor(), "Export");
   if (result == JFileChooser.APPROVE_OPTION) {
     _lastDirectory = chooser.getCurrentDirectory().getAbsolutePath();
     try {
       System.out.println("Exporting to " + chooser.getSelectedFile().getAbsolutePath());
       HssfTableUtils.export(
           _sortableTable,
           chooser.getSelectedFile().getAbsolutePath(),
           "SortableTable",
           false,
           true,
           new HssfTableUtils.DefaultCellValueConverter() {
             @Override
             public int getDataFormat(JTable table, Object value, int rowIndex, int columnIndex) {
               if (value instanceof Double) {
                 return 2; // use 0.00 format
               } else if (value instanceof Date) {
                 return 0xe; // use "m/d/yy" format
               }
               return super.getDataFormat(table, value, rowIndex, columnIndex);
             }
           });
       System.out.println("Exported");
     } catch (IOException e1) {
       e1.printStackTrace();
     }
   }
 }
  /**
   * Returns a list of files.
   *
   * @return a list of files
   */
  public Vector<File> getFiles() {
    synchronized (fileCache) {
      if (files != null) {
        return files;
      }
      files = new Vector<File>();
      directories = new Vector<File>();
      directories.addElement(
          filechooser
              .getFileSystemView()
              .createFileObject(filechooser.getCurrentDirectory(), ".."));

      for (int i = 0; i < getSize(); i++) {
        File f = fileCache.get(i);
        if (filechooser.isTraversable(f)) {
          directories.add(f);
        } else {
          files.add(f);
        }
      }
      return files;
    }
  }
Exemplo n.º 13
0
  public ConverterView(ConverterModel model) {
    //        this.model = model;

    this.fileChooser = new JFileChooser();
    this.fileChooser.setFileFilter(new ConverterFileFilter());
    this.fileChooser.setMultiSelectionEnabled(true);

    setTitle(getGuiString(model.getName()));

    this.addButton = new JButton(getGuiString("buttons.change"));
    this.addButton.addActionListener(
        e -> {
          if (this.changeActionListener != null) {
            Action details = fileChooser.getActionMap().get("viewTypeDetails");
            details.actionPerformed(null);
            if (FilePath.getFilePath(this.getTitle()) != null) {
              File file = new File(FilePath.getFilePath(this.getTitle()).getPath());
              fileChooser.setCurrentDirectory(file);
            }
            int ret = fileChooser.showDialog(null, getGuiString("buttons.openFile"));
            if (ret == JFileChooser.APPROVE_OPTION) {
              File[] files = fileChooser.getSelectedFiles();
              FilePath.setFilePath(this.getTitle(), fileChooser.getCurrentDirectory().getPath());
              this.changeActionListener.actionPerformed(files);
            }
          }
          hide();
        });
    this.cancelButton = new JButton(getGuiString("buttons.cancel"));
    this.cancelButton.addActionListener(
        e -> {
          hide();
        });

    buildLayout();
    show();
  }
Exemplo n.º 14
0
  public SQLiteDataBrowser() {
    SQLiteDbManager dbManager = new SQLiteDbManager();

    setLayout(new BorderLayout());

    showTablesList = new JList();
    showTablesList.setLayoutOrientation(JList.VERTICAL_WRAP);
    showTablesList.setSelectedIndex(ListSelectionModel.SINGLE_SELECTION);
    showTablesList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    showTablesList.setFont(new Font("Times New Roman", Font.PLAIN, 13));
    showTablesList.setDragEnabled(false);
    showTablesList.setFixedCellWidth(150);
    showTablesList.setVisibleRowCount(-1);
    showTablesList.setEnabled(false);

    showTablesListScroller = new JScrollPane(showTablesList);
    showTablesListScroller.setBorder(
        BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "List of Tables"));
    showTablesListScroller.setPreferredSize(new Dimension(160, this.getHeight()));

    add(showTablesListScroller, BorderLayout.EAST);

    loadDbPanel = new JPanel(new FlowLayout());
    loadDbPanel.setBackground(new Color(0xe8e8e8));
    loadDbPanel.setPreferredSize(new Dimension(getWidth(), 40));

    loadDbLabel = new JLabel("Load SQLite Database: ");
    loadDbLabel.setToolTipText("Possible extensions being .sqlite|.sqlite3|.db|.db3");

    loadedDbPath = new JTextField("Click browse to choose the database file.", 60);
    loadedDbPath.setForeground(Color.GRAY);
    loadedDbPath.setFont(new Font("Times New Roman", Font.ITALIC, 13));
    loadedDbPath.setEditable(false);

    lastFolderLocation = new File(Utils.getUserHome());
    fc = new JFileChooser(lastFolderLocation);

    browseDb = new JButton("Browse");
    browseDb.addActionListener(
        actionEvent -> {
          int retVal = fc.showOpenDialog(SQLiteDataBrowser.this);
          if (retVal == JFileChooser.APPROVE_OPTION) {
            File dbPath = fc.getSelectedFile();
            if (Utils.checkIfSQLiteDb(dbPath)) {
              loadedDbPath.setText(dbPath.toString());
              lastFolderLocation = fc.getCurrentDirectory();
              new SwingWorker<Void, Void>() {

                @Override
                protected Void doInBackground() throws Exception {
                  try {
                    dbManager.setDbPath(dbPath.toString());
                    dbManager.initialize();
                    showTablesList.setListData(dbManager.getTables().toArray());
                    showTablesList.setEnabled(true);
                  } catch (SQLException e) {
                    e.printStackTrace();
                  }
                  return null;
                }
              }.execute();
            } else {
              JOptionPane.showMessageDialog(
                  SQLiteDataBrowser.this,
                  "The Selected file is not in SQLite Format",
                  "File Format Error",
                  JOptionPane.ERROR_MESSAGE);
              loadedDbPath.setText("Click browse to choose the database file.");
            }
          }
        });

    loadDbPanel.add(loadDbLabel);
    loadDbPanel.add(loadedDbPath);
    loadDbPanel.add(browseDb);

    loadDbRecords = new JLabel("Records Fetched (Rows x Cols): ");
    loadDbRecords.setFont(new Font("Times New Roman", Font.ITALIC, 12));
    loadDbPanel.add(loadDbRecords);

    loadDbRecordsCount = new JLabel();
    loadDbRecordsCount.setFont(new Font("Times New Roman", Font.ITALIC, 12));
    loadDbPanel.add(loadDbRecordsCount);

    final class DataBrowserTableModal extends DefaultTableModel {

      public DataBrowserTableModal() {}

      public DataBrowserTableModal(Object[][] tableData, Object[] colNames) {
        super(tableData, colNames);
      }

      @Override
      public void setDataVector(Object[][] tableData, Object[] colNames) {
        super.setDataVector(tableData, colNames);
      }

      @Override
      public boolean isCellEditable(int row, int column) {
        return false;
      }
    }

    DataBrowserTableModal tableModal = new DataBrowserTableModal();
    defaultTableModel = tableModal;

    table = new JTable();
    table.setModel(defaultTableModel);

    showTablesList.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent evt) {
            JList list = (JList) evt.getSource();
            if (evt.getClickCount() == 2) {
              String tableName = list.getSelectedValue().toString();

              new SwingWorker<Void, Void>() {

                @Override
                protected Void doInBackground() throws Exception {
                  try {
                    ResultSet rs = dbManager.executeQuery("SELECT * from " + tableName);
                    Vector<String> columnNames = dbManager.getColumnNames(rs);
                    Vector<Vector<Object>> tableData = new Vector<>();
                    while (rs.next()) {
                      Vector<Object> vector = new Vector<>();

                      for (int i = 1; i <= columnNames.size(); i++) {
                        vector.add(rs.getObject(i));
                      }
                      tableData.add(vector);
                    }
                    defaultTableModel.setDataVector(tableData, columnNames);
                  } catch (SQLException e) {
                    e.printStackTrace();
                  }

                  loadDbRecordsCount.setText(
                      defaultTableModel.getRowCount() + " x " + defaultTableModel.getColumnCount());

                  if (defaultTableModel.getColumnCount() < 5) {
                    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
                  } else {
                    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
                  }

                  return null;
                }
              }.execute();
            }
          }
        });

    tableScrollPane = new JScrollPane(table);
    tableScrollPane.setHorizontalScrollBarPolicy(
        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    tableScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    tableScrollPane.setPreferredSize(new Dimension(getWidth(), getHeight()));
    add(tableScrollPane, BorderLayout.CENTER);

    add(loadDbPanel, BorderLayout.NORTH);
  }
Exemplo n.º 15
0
    public void actionPerformed(ActionEvent e) {
      if (isDirectorySelected()) {
        File dir = getDirectory();
        if (dir != null) {
          try {
            // Strip trailing ".."
            dir = ShellFolder.getNormalizedFile(dir);
          } catch (IOException ex) {
            // Ok, use f as is
          }
          changeDirectory(dir);
          return;
        }
      }

      JFileChooser chooser = getFileChooser();

      String filename = getFileName();
      FileSystemView fs = chooser.getFileSystemView();
      File dir = chooser.getCurrentDirectory();

      if (filename != null) {
        // Remove whitespaces from end of filename
        int i = filename.length() - 1;

        while (i >= 0 && filename.charAt(i) <= ' ') {
          i--;
        }

        filename = filename.substring(0, i + 1);
      }

      if (filename == null || filename.length() == 0) {
        // no file selected, multiple selection off, therefore cancel the approve action
        resetGlobFilter();
        return;
      }

      File selectedFile = null;
      File[] selectedFiles = null;

      // Unix: Resolve '~' to user's home directory
      if (File.separatorChar == '/') {
        if (filename.startsWith("~/")) {
          filename = System.getProperty("user.home") + filename.substring(1);
        } else if (filename.equals("~")) {
          filename = System.getProperty("user.home");
        }
      }

      if (chooser.isMultiSelectionEnabled()
          && filename.length() > 1
          && filename.charAt(0) == '"'
          && filename.charAt(filename.length() - 1) == '"') {
        List<File> fList = new ArrayList<File>();

        String[] files = filename.substring(1, filename.length() - 1).split("\" \"");
        // Optimize searching files by names in "children" array
        Arrays.sort(files);

        File[] children = null;
        int childIndex = 0;

        for (String str : files) {
          File file = fs.createFileObject(str);
          if (!file.isAbsolute()) {
            if (children == null) {
              children = fs.getFiles(dir, false);
              Arrays.sort(children);
            }
            for (int k = 0; k < children.length; k++) {
              int l = (childIndex + k) % children.length;
              if (children[l].getName().equals(str)) {
                file = children[l];
                childIndex = l + 1;
                break;
              }
            }
          }
          fList.add(file);
        }

        if (!fList.isEmpty()) {
          selectedFiles = fList.toArray(new File[fList.size()]);
        }
        resetGlobFilter();
      } else {
        selectedFile = fs.createFileObject(filename);
        if (!selectedFile.isAbsolute()) {
          selectedFile = fs.getChild(dir, filename);
        }
        // check for wildcard pattern
        FileFilter currentFilter = chooser.getFileFilter();
        if (!selectedFile.exists() && isGlobPattern(filename)) {
          changeDirectory(selectedFile.getParentFile());
          if (globFilter == null) {
            globFilter = new GlobFilter();
          }
          try {
            globFilter.setPattern(selectedFile.getName());
            if (!(currentFilter instanceof GlobFilter)) {
              actualFileFilter = currentFilter;
            }
            chooser.setFileFilter(null);
            chooser.setFileFilter(globFilter);
            return;
          } catch (PatternSyntaxException pse) {
            // Not a valid glob pattern. Abandon filter.
          }
        }

        resetGlobFilter();

        // Check for directory change action
        boolean isDir = (selectedFile != null && selectedFile.isDirectory());
        boolean isTrav = (selectedFile != null && chooser.isTraversable(selectedFile));
        boolean isDirSelEnabled = chooser.isDirectorySelectionEnabled();
        boolean isFileSelEnabled = chooser.isFileSelectionEnabled();
        boolean isCtrl =
            (e != null
                && (e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0);

        if (isDir && isTrav && (isCtrl || !isDirSelEnabled)) {
          changeDirectory(selectedFile);
          return;
        } else if ((isDir || !isFileSelEnabled)
            && (!isDir || !isDirSelEnabled)
            && (!isDirSelEnabled || selectedFile.exists())) {
          selectedFile = null;
        }
      }

      if (selectedFiles != null || selectedFile != null) {
        if (selectedFiles != null || chooser.isMultiSelectionEnabled()) {
          if (selectedFiles == null) {
            selectedFiles = new File[] {selectedFile};
          }
          chooser.setSelectedFiles(selectedFiles);
          // Do it again. This is a fix for bug 4949273 to force the
          // selected value in case the ListSelectionModel clears it
          // for non-existing file names.
          chooser.setSelectedFiles(selectedFiles);
        } else {
          chooser.setSelectedFile(selectedFile);
        }
        chooser.approveSelection();
      } else {
        if (chooser.isMultiSelectionEnabled()) {
          chooser.setSelectedFiles(null);
        } else {
          chooser.setSelectedFile(null);
        }
        chooser.cancelSelection();
      }
    }
Exemplo n.º 16
0
  @Override
  void mergeTiffs() {
    JFileChooser jf = new JFileChooser();
    jf.setDialogTitle(bundle.getString("Select") + " Input Images");
    jf.setCurrentDirectory(imageFolder);
    jf.setMultiSelectionEnabled(true);
    FileFilter tiffFilter = new SimpleFilter("tif;tiff", "TIFF");
    FileFilter jpegFilter = new SimpleFilter("jpg;jpeg", "JPEG");
    FileFilter gifFilter = new SimpleFilter("gif", "GIF");
    FileFilter pngFilter = new SimpleFilter("png", "PNG");
    FileFilter bmpFilter = new SimpleFilter("bmp", "Bitmap");
    FileFilter allImageFilter =
        new SimpleFilter("tif;tiff;jpg;jpeg;gif;png;bmp", "All Image Files");

    jf.addChoosableFileFilter(tiffFilter);
    jf.addChoosableFileFilter(jpegFilter);
    jf.addChoosableFileFilter(gifFilter);
    jf.addChoosableFileFilter(pngFilter);
    jf.addChoosableFileFilter(bmpFilter);
    jf.addChoosableFileFilter(allImageFilter);

    if (selectedFilter != null) {
      jf.setFileFilter(selectedFilter);
    }

    jf.setAcceptAllFileFilterUsed(false);
    if (jf.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      selectedFilter = jf.getFileFilter();
      final File[] inputs = jf.getSelectedFiles();
      imageFolder = jf.getCurrentDirectory();

      jf = new JFileChooser();
      jf.setDialogTitle(bundle.getString("Save") + " Multi-page TIFF Image");
      jf.setCurrentDirectory(imageFolder);
      jf.setFileFilter(tiffFilter);
      jf.setAcceptAllFileFilterUsed(false);
      if (jf.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
        File selectedFile = jf.getSelectedFile();
        if (!(selectedFile.getName().endsWith(".tif")
            || selectedFile.getName().endsWith(".tiff"))) {
          selectedFile = new File(selectedFile.getParent(), selectedFile.getName() + ".tif");
        }

        final File outputTiff = selectedFile;
        if (outputTiff.exists()) {
          outputTiff.delete();
        }

        jLabelStatus.setText(bundle.getString("Merge_running..."));
        jProgressBar1.setIndeterminate(true);
        jProgressBar1.setString(bundle.getString("Merge_running..."));
        jProgressBar1.setVisible(true);
        getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        getGlassPane().setVisible(true);

        SwingWorker worker =
            new SwingWorker<File, Void>() {

              @Override
              protected File doInBackground() throws Exception {
                ImageIOHelper.mergeTiff(inputs, outputTiff);
                return outputTiff;
              }

              @Override
              protected void done() {
                jLabelStatus.setText(bundle.getString("Mergecompleted"));
                jProgressBar1.setIndeterminate(false);
                jProgressBar1.setString(bundle.getString("Mergecompleted"));

                try {
                  File result = get();
                  JOptionPane.showMessageDialog(
                      GuiWithTools.this,
                      bundle.getString("Mergecompleted")
                          + result.getName()
                          + bundle.getString("created"),
                      APP_NAME,
                      JOptionPane.INFORMATION_MESSAGE);
                } catch (InterruptedException ignore) {
                  ignore.printStackTrace();
                } catch (java.util.concurrent.ExecutionException e) {
                  String why = null;
                  Throwable cause = e.getCause();
                  if (cause != null) {
                    if (cause instanceof OutOfMemoryError) {
                      why = bundle.getString("OutOfMemoryError");
                    } else {
                      why = cause.getMessage();
                    }
                  } else {
                    why = e.getMessage();
                  }
                  e.printStackTrace();
                  JOptionPane.showMessageDialog(
                      GuiWithTools.this, why, APP_NAME, JOptionPane.ERROR_MESSAGE);
                } finally {
                  jProgressBar1.setVisible(false);
                  getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                  getGlassPane().setVisible(false);
                }
              }
            };

        worker.execute();
      }
    }
  }
  public void installComponents(JFileChooser fc) {
    fc.setLayout(new BorderLayout(10, 10));
    fc.setAlignmentX(JComponent.CENTER_ALIGNMENT);

    JPanel interior =
        new JPanel() {
          public Insets getInsets() {
            return insets;
          }
        };
    align(interior);
    interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS));

    fc.add(interior, BorderLayout.CENTER);

    // PENDING(jeff) - I18N
    JLabel l = new JLabel(pathLabelText);
    l.setDisplayedMnemonic(pathLabelMnemonic);
    align(l);
    interior.add(l);

    File currentDirectory = fc.getCurrentDirectory();
    String curDirName = null;
    if (currentDirectory != null) {
      curDirName = currentDirectory.getPath();
    }
    pathField =
        new JTextField(curDirName) {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(pathField);
    align(pathField);

    // Change to folder on return
    pathField.addActionListener(getUpdateAction());
    interior.add(pathField);

    interior.add(Box.createRigidArea(vstrut10));

    // CENTER: left, right accessory
    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.LINE_AXIS));
    align(centerPanel);

    // left panel - Filter & folderList
    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
    align(leftPanel);

    // add the filter PENDING(jeff) - I18N
    l = new JLabel(filterLabelText);
    l.setDisplayedMnemonic(filterLabelMnemonic);
    align(l);
    leftPanel.add(l);

    filterComboBox =
        new JComboBox() {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(filterComboBox);
    filterComboBoxModel = createFilterComboBoxModel();
    filterComboBox.setModel(filterComboBoxModel);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    fc.addPropertyChangeListener(filterComboBoxModel);
    align(filterComboBox);
    leftPanel.add(filterComboBox);

    // leftPanel.add(Box.createRigidArea(vstrut10));

    // Add the Folder List PENDING(jeff) - I18N
    l = new JLabel(foldersLabelText);
    l.setDisplayedMnemonic(foldersLabelMnemonic);
    align(l);
    leftPanel.add(l);
    JScrollPane sp = createDirectoryList();
    sp.getVerticalScrollBar().setFocusable(false);
    sp.getHorizontalScrollBar().setFocusable(false);
    l.setLabelFor(sp.getViewport().getView());
    leftPanel.add(sp);

    // create files list
    JPanel rightPanel = new JPanel();
    align(rightPanel);
    rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS));

    l = new JLabel(filesLabelText);
    l.setDisplayedMnemonic(filesLabelMnemonic);
    align(l);
    rightPanel.add(l);
    sp = createFilesList();
    l.setLabelFor(sp);
    rightPanel.add(sp);

    centerPanel.add(leftPanel);
    centerPanel.add(Box.createRigidArea(hstrut10));
    centerPanel.add(rightPanel);

    JComponent accessoryPanel = getAccessoryPanel();
    JComponent accessory = fc.getAccessory();
    if (accessoryPanel != null) {
      if (accessory == null) {
        accessoryPanel.setPreferredSize(ZERO_ACC_SIZE);
        accessoryPanel.setMaximumSize(ZERO_ACC_SIZE);
      } else {
        getAccessoryPanel().add(accessory, BorderLayout.CENTER);
        accessoryPanel.setPreferredSize(PREF_ACC_SIZE);
        accessoryPanel.setMaximumSize(MAX_SIZE);
      }
      align(accessoryPanel);
      centerPanel.add(accessoryPanel);
    }
    interior.add(centerPanel);
    interior.add(Box.createRigidArea(vstrut10));

    // add the filename field PENDING(jeff) - I18N
    l = new JLabel(enterFileNameLabelText);
    l.setDisplayedMnemonic(enterFileNameLabelMnemonic);
    align(l);
    interior.add(l);

    filenameTextField =
        new JTextField() {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(filenameTextField);
    filenameTextField.addActionListener(getApproveSelectionAction());
    align(filenameTextField);
    filenameTextField.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    interior.add(filenameTextField);

    bottomPanel = getBottomPanel();
    bottomPanel.add(new JSeparator(), BorderLayout.NORTH);

    // Add buttons
    JPanel buttonPanel = new JPanel();
    align(buttonPanel);
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.add(Box.createGlue());

    approveButton =
        new JButton(getApproveButtonText(fc)) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    approveButton.setMnemonic(getApproveButtonMnemonic(fc));
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    align(approveButton);
    approveButton.setMargin(buttonMargin);
    approveButton.addActionListener(getApproveSelectionAction());
    buttonPanel.add(approveButton);
    buttonPanel.add(Box.createGlue());

    JButton updateButton =
        new JButton(updateButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    updateButton.setMnemonic(updateButtonMnemonic);
    updateButton.setToolTipText(updateButtonToolTipText);
    align(updateButton);
    updateButton.setMargin(buttonMargin);
    updateButton.addActionListener(getUpdateAction());
    buttonPanel.add(updateButton);
    buttonPanel.add(Box.createGlue());

    JButton cancelButton =
        new JButton(cancelButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    cancelButton.setMnemonic(cancelButtonMnemonic);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    align(cancelButton);
    cancelButton.setMargin(buttonMargin);
    cancelButton.addActionListener(getCancelSelectionAction());
    buttonPanel.add(cancelButton);
    buttonPanel.add(Box.createGlue());

    JButton helpButton =
        new JButton(helpButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    helpButton.setMnemonic(helpButtonMnemonic);
    helpButton.setToolTipText(helpButtonToolTipText);
    align(helpButton);
    helpButton.setMargin(buttonMargin);
    helpButton.setEnabled(false);
    buttonPanel.add(helpButton);
    buttonPanel.add(Box.createGlue());

    bottomPanel.add(buttonPanel, BorderLayout.SOUTH);
    if (fc.getControlButtonsAreShown()) {
      fc.add(bottomPanel, BorderLayout.SOUTH);
    }
  }