Package javax.swing

Examples of javax.swing.JFileChooser


  public static JButton createBrowseButton(final Component parent, final JTextField tf) {
    JButton bt = new JButton(mLocalizer.msg("change", "Change"));
    bt.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent event) {
        File file = new File(tf.getText());
        JFileChooser fileChooser = new JFileChooser(file.getParent());
        String[] extArr = { ".jpg", ".jpeg", ".gif", ".png" };
        fileChooser.setFileFilter(new util.ui.ExtensionFileFilter(extArr, ".jpg, .gif, png"));
        if (fileChooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
          File selection = fileChooser.getSelectedFile();
          if (selection != null) {
            tf.setText(selection.getAbsolutePath());
          }
        }
      }
View Full Code Here


    /**
     * Creates the file chooser the user will use to save/load files with.
     */
    protected void createFileChooser() {
     
      m_FileChooser = new JFileChooser(new File(System.getProperty("user.dir")));
      m_FileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    }
View Full Code Here

    saveButton.setMnemonic('S');
    saveButton.setToolTipText("Saves the output to a file");
    saveButton.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent evt){
        JFileChooser filechooser = new JFileChooser();
        int result = filechooser.showSaveDialog(dialog);
        if (result == JFileChooser.APPROVE_OPTION) {
          try {
            BufferedWriter writer = new BufferedWriter(
                                      new FileWriter(
                                        filechooser.getSelectedFile()));
            writer.write(textData.getText());
            writer.flush();
            writer.close();
            JOptionPane.showMessageDialog(
              dialog,
              "Output successfully saved to file '"
              + filechooser.getSelectedFile() + "'!",
              "Information",
              JOptionPane.INFORMATION_MESSAGE);
          }
          catch (Exception e) {
            e.printStackTrace();
View Full Code Here

  }

  protected void setupFileChooser() {
    if (m_fileChooser == null) {
      m_fileChooser =
        new JFileChooser(new File(System.getProperty("user.dir")));
    }

    m_fileChooser.addChoosableFileFilter(m_binaryFilter);
    if (KOML.isPresent()) {
      m_fileChooser.addChoosableFileFilter(m_KOMLFilter);
View Full Code Here

          FileEnvironmentField.this.setText(selected.toString());
        }       
      }
    });
   
    final JFileChooser embeddedEditor = (JFileChooser)m_fileEditor.getCustomEditor();
    embeddedEditor.setFileSelectionMode(JFileChooser.FILES_ONLY);
    ExtensionFileFilter ff =
      new ExtensionFileFilter(".model", "Serialized Weka classifier (*.model)");
    embeddedEditor.addChoosableFileFilter(ff);   
   
    m_browseBut = new JButton("Browse...");
    m_browseBut.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        try {
          String modelPath = getText();
          if (modelPath != null) {
            try {
              modelPath = m_env.substitute(modelPath);
            } catch (Exception ex) {             
            }
           
            File toSet = new File(modelPath);           
            if (toSet.isFile()) {
              m_fileEditor.setValue(new File(modelPath));
              toSet = toSet.getParentFile();             
            }
            if (toSet.isDirectory()) {
              embeddedEditor.setCurrentDirectory(toSet);
            }
          }
         
          showFileEditor();
        } catch (Exception ex) {
View Full Code Here

   * Add a file filter to use
   *
   * @param toSet the file filter to use
   */
  public void addFileFilter(FileFilter toSet) {
    JFileChooser embeddedEditor = (JFileChooser)m_fileEditor.getCustomEditor();
    embeddedEditor.addChoosableFileFilter(toSet);
  }
View Full Code Here

 
  /**
   * Resets the list of choosable file filters.
   */
  public void resetFileFilters() {
    JFileChooser embeddedEditor = (JFileChooser)m_fileEditor.getCustomEditor();
    embeddedEditor.resetChoosableFileFilters();
  }
View Full Code Here

    if (forceNeedsSourceFile || dataSource.getSourceFile() == null) {
      // Then ask the user to select the source file.
      Frame frame =
        Designer.findWindowFor(this) == null ?
        null : Designer.findWindowFor(this).getFrame();
      JFileChooser chooser = Designer.getChooser();
      chooser.setDialogTitle(I18N.get("Report.select_source_file"));
      Designer.setPrefsDir(chooser, "dataSourceDir");
      int returnVal = chooser.showOpenDialog(frame);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        Designer.savePrefsDir(chooser, "dataSourceDir");
        dataSource.setSourceFile(chooser.getSelectedFile().getPath());
      } else {
        throw new UserCancellationException(I18N.get("Report.user_cancelled"));
      }
    }
  }
View Full Code Here

  /**
   * Change the Icon
   */
  private void changeIcon() {
    JFileChooser fileChooser = new JFileChooser(mIconFile);
    String[] extArr = { ".jpg", ".jpeg", ".gif", ".png" };
    fileChooser.setFileFilter(new util.ui.ExtensionFileFilter(extArr, ".jpg, .gif, .png"));
    if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      File selection = fileChooser.getSelectedFile();
      if (selection != null) {
        mIconFile = selection;
        mIconLabel.setIcon(createUserIcon());
      }
    }
View Full Code Here

    mChooseButton = new JButton(Localizer.getLocalization(Localizer.I18N_SELECT));
    mChooseButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent event) {
        if (mFileChooser==null) {
          mFileChooser=new JFileChooser();

          if (OperatingSystem.isMacOs()) {
            mFileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
          } else {
            mFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
View Full Code Here

TOP

Related Classes of javax.swing.JFileChooser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.