Examples of JFileChooser


Examples of javax.swing.JFileChooser

    private File lastFile = null;
   
    public void actionPerformed(ActionEvent event) {
      Object src = event.getSource();
      if (src == open) {
        JFileChooser chooser = JFileChoosers.createSelected(lastFile);
        chooser.setDialogTitle(Strings.get("openButton"));
        int choice = chooser.showOpenDialog(HexFrame.this);
        if (choice == JFileChooser.APPROVE_OPTION) {
          File f = chooser.getSelectedFile();
          try {
            HexFile.open(model, f);
            lastFile = f;
          } catch (IOException e) {
            JOptionPane.showMessageDialog(HexFrame.this, e.getMessage(),
                Strings.get("hexOpenErrorTitle"), JOptionPane.ERROR_MESSAGE);
          }
        }
      } else if (src == save) {
        JFileChooser chooser = JFileChoosers.createSelected(lastFile);
        chooser.setDialogTitle(Strings.get("saveButton"));
        int choice = chooser.showSaveDialog(HexFrame.this);
        if (choice == JFileChooser.APPROVE_OPTION) {
          File f = chooser.getSelectedFile();
          try {
            HexFile.save(f, model);
            lastFile = f;
          } catch (IOException e) {
            JOptionPane.showMessageDialog(HexFrame.this, e.getMessage(),
View Full Code Here

Examples of javax.swing.JFileChooser

class TemplateOptions extends OptionsPanel {
  private class MyListener implements ActionListener, PropertyChangeListener {
    public void actionPerformed(ActionEvent event) {
      Object src = event.getSource();
      if (src == templateButton) {
        JFileChooser chooser = JFileChoosers.create();
        chooser.setDialogTitle(Strings.get("selectDialogTitle"));
        chooser.setApproveButtonText(Strings.get("selectDialogButton"));
        int action = chooser.showOpenDialog(getPreferencesFrame());
        if (action == JFileChooser.APPROVE_OPTION) {
          File file = chooser.getSelectedFile();
          FileInputStream reader = null;
          InputStream reader2 = null;
          try {
            Loader loader = new Loader(getPreferencesFrame());
            reader = new FileInputStream(file);
View Full Code Here

Examples of javax.swing.JFileChooser

      return;
    }
   
    // Then display file chooser
    Loader loader = proj.getLogisimFile().getLoader();
    JFileChooser chooser = loader.createChooser();
    if (circuits.size() > 1) {
      chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      chooser.setDialogTitle(Strings.get("exportImageDirectorySelect"));
    } else {
      chooser.setFileFilter(filter);
      chooser.setDialogTitle(Strings.get("exportImageFileSelect"));
    }
    int returnVal = chooser.showDialog(frame, Strings.get("exportImageButton"));
    if (returnVal != JFileChooser.APPROVE_OPTION) return;

    // Determine whether destination is valid
    File dest = chooser.getSelectedFile();
    chooser.setCurrentDirectory(dest.isDirectory() ? dest : dest.getParentFile());
    if (dest.exists()) {
      if (!dest.isDirectory()) {
        int confirm = JOptionPane.showConfirmDialog(proj.getFrame(),
          Strings.get("confirmOverwriteMessage"),
          Strings.get("confirmOverwriteTitle"),
View Full Code Here

Examples of javax.swing.JFileChooser

 
  public static JFileChooser createSelected(File selected) {
    if (selected == null) {
      return create();
    } else {
      JFileChooser ret = createAt(selected.getParentFile());
      ret.setSelectedFile(selected);
      return ret;
    }
  }
View Full Code Here

Examples of javax.swing.JFileChooser

      s.getContents().clear();
    }
  }

  private void doLoad() {
    JFileChooser chooser = proj.createChooser();
    File oldSelected = factory.getCurrentImage(instance);
    if (oldSelected != null) chooser.setSelectedFile(oldSelected);
    chooser.setDialogTitle(Strings.get("ramLoadDialogTitle"));
    int choice = chooser.showOpenDialog(frame);
    if (choice == JFileChooser.APPROVE_OPTION) {
      File f = chooser.getSelectedFile();
      try {
        factory.loadImage(circState.getInstanceState(instance), f);
      } catch (IOException e) {
        JOptionPane.showMessageDialog(frame, e.getMessage(),
            Strings.get("ramLoadErrorTitle"), JOptionPane.ERROR_MESSAGE);
View Full Code Here

Examples of javax.swing.JFileChooser

  }

  private void doSave() {
    MemState s = factory.getState(instance, circState);

    JFileChooser chooser = proj.createChooser();
    File oldSelected = factory.getCurrentImage(instance);
    if (oldSelected != null) chooser.setSelectedFile(oldSelected);
    chooser.setDialogTitle(Strings.get("ramSaveDialogTitle"));
    int choice = chooser.showSaveDialog(frame);
    if (choice == JFileChooser.APPROVE_OPTION) {
      File f = chooser.getSelectedFile();
      try {
        HexFile.save(f, s.getContents());
        factory.setCurrentImage(instance, f);
      } catch (IOException e) {
        JOptionPane.showMessageDialog(frame, e.getMessage(),
View Full Code Here

Examples of javax.swing.JFileChooser

   * @return selected File
   * @param programs
   *          programs that are exported
   */
  private File chooseFile(Program[] programs) {
    JFileChooser select = new JFileChooser();

    ExtensionFileFilter vCal = new ExtensionFileFilter(mExtension,
        mExtensionFilter);
    select.addChoosableFileFilter(vCal);
    String ext = "." + mExtension;

    if (mSavePath != null) {
      select.setSelectedFile(new File(mSavePath));
      select.setFileFilter(vCal);
    }

    // check if all programs have same title. if so, use as filename
    String fileName = programs[0].getTitle();
    for (int i = 1; i < programs.length; i++) {
      if (!programs[i].getTitle().equals(fileName)) {
        fileName = "";
      }
    }

    fileName = CalendarToolbox.cleanFilename(fileName);

    if (StringUtils.isNotEmpty(fileName)) {
      if (mSavePath == null) {
        mSavePath = "";
      }
      select.setSelectedFile(new File((new File(mSavePath).getParent())
          + File.separator + fileName + ext));
    }

    if (select.showSaveDialog(CalendarExportPlugin.getInstance()
        .getBestParentFrame()) == JFileChooser.APPROVE_OPTION) {

      String filename = select.getSelectedFile().getAbsolutePath();

      if (!filename.toLowerCase().endsWith(ext)) {
        if (filename.endsWith(".")) {
          filename = filename.substring(0, filename.length() - 1);
        }
View Full Code Here

Examples of javax.swing.JFileChooser

 
  /**
   * Call the FileChooser for the executable
   */
  private void changeFile() {
    JFileChooser chooser = new JFileChooser(new File(mFile.getText()));
    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      mFile.setText(chooser.getSelectedFile().getAbsolutePath());
    }
  }
View Full Code Here

Examples of javax.swing.JFileChooser

   
    /**
     * invoked when the user clicks the Button to open an FileChooser - Dialog
     */
    private void pathButtonPressed(ActionEvent e) {
        JFileChooser f = new JFileChooser();
        if (f.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
            mData.setProgramPath(f.getSelectedFile().toString());
            mPathTextField.setText(mData.getProgramPath());
        }
    }
View Full Code Here

Examples of javax.swing.JFileChooser

    rootpathField.setColumns(10);
   
    JButton selectRootPathButton = new JButton("\u9009\u62E9");
    selectRootPathButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        JFileChooser jfc = new JFileChooser();
        jfc.setName("请选择本地存放文件夹");
        jfc.setDialogTitle("请选择本地存放文件夹");
        jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int rc = jfc.showOpenDialog(frmEverbox);
        if(rc == JFileChooser.APPROVE_OPTION )
          rootpathField.setText(jfc.getSelectedFile().getAbsolutePath());
      }
    });
    sl_panel.putConstraint(SpringLayout.NORTH, selectRootPathButton, -4, SpringLayout.NORTH, label_3);
    sl_panel.putConstraint(SpringLayout.WEST, selectRootPathButton, 6, SpringLayout.EAST, rootpathField);
    panel.add(selectRootPathButton);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.