Package javax.swing

Examples of javax.swing.JFileChooser


        ApplicationWindow aw = getApplicationWindow();
        final StatusBar bar = aw.getStatusBar();
        ProgressMonitor pm = bar.getProgressMonitor();

        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle(tr.get(ID + ".fileDialog"));
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int res = fc.showOpenDialog(aw.getControl());
        if (res != JFileChooser.APPROVE_OPTION) {
            bar.setMessage(tr.get(ID + ".noFileSelected"));
            return;
        }

        file = fc.getSelectedFile();
        if (!file.isDirectory()) {
            int resultOP = JOptionPane.showConfirmDialog(null, tr.get(ID + ".confirmation.message"),
                    tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
            if (resultOP != JOptionPane.OK_OPTION) {
                return;
View Full Code Here


          public String showOpenDialog(View parentView,
                                     String dialogTitle,
                                     ContentType contentType) {
            if (contentType == ContentType.USER_DEFINED) {
              // Let user choose multiple model files
              JFileChooser fileChooser = new JFileChooser();
              // Update current directory
              if (this.modelsDirectory != null) {
                fileChooser.setCurrentDirectory(this.modelsDirectory);
              }
              fileChooser.setDialogTitle(dialogTitle);
              fileChooser.setMultiSelectionEnabled(true);
              if (fileChooser.showOpenDialog((JComponent)parentView) == JFileChooser.APPROVE_OPTION) {
                // Retrieve current directory for future calls
                this.modelsDirectory = fileChooser.getCurrentDirectory();
                // Return selected files separated by path separator character
                String files = "";
                for (File selectedFile : fileChooser.getSelectedFiles()) {
                  if (files.length() > 0) {
                    files += File.pathSeparator;
                  }
                  files += selectedFile;
                }
View Full Code Here

        ApplicationWindow aw = getApplicationWindow();
        final StatusBar bar = aw.getStatusBar();
        final ProgressMonitor pm = bar.getProgressMonitor();

        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle(tr.get(ID + ".fileDialog"));
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int res = fc.showOpenDialog(aw.getControl());
        if (res != JFileChooser.APPROVE_OPTION) {
            bar.setMessage(tr.get(ID + ".noFileSelected"));
            return;
        }
        file = fc.getSelectedFile();
        if (!file.isDirectory()) {
            int resultOP = JOptionPane.showConfirmDialog(null, tr.get(ID + ".confirmation.message"),
                    tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
            if (resultOP != JOptionPane.OK_OPTION) {
                return;
View Full Code Here

        try {
            if (download) {
                // see MySwingWorker.construct -> it could be that site is not accessible
                // -> then the ui should not freeze
            } else {
                JFileChooser fc = new JFileChooser();
                fc.setDialogTitle(tr.get(ID + ".fileDialog"));
                int resultFC = fc.showOpenDialog(aw.getControl());
                if (resultFC != JFileChooser.APPROVE_OPTION) {
                    bar.setMessage(tr.get(ID + ".noFileSelected"));
                    return;
                }
                file = fc.getSelectedFile();
                if (!file.getName().endsWith(".tim")) {
                    int resultOP = JOptionPane.showConfirmDialog(null, tr.get(ID + ".confirmation.message"),
                            tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
                    if (resultOP != JOptionPane.OK_OPTION) {
                        return;
View Full Code Here

        try {
            int resultDownload = JOptionPane.showConfirmDialog(null, tr.get(ID + ".downloadQuestion"),
                    tr.get(ID + ".downloadQuestion"), JOptionPane.YES_NO_OPTION);
            if (resultDownload == JOptionPane.YES_OPTION) {
            } else {
                JFileChooser fc = new JFileChooser();
                fc.setDialogTitle(tr.get(ID + ".fileDialog"));
                int res = fc.showOpenDialog(getApplicationWindow().getControl());
                if (res != JFileChooser.APPROVE_OPTION) {
                    bar.setMessage(tr.get(ID + ".noFileSelected"));
                    return;
                }

                file = fc.getSelectedFile();

                if (!file.getName().endsWith(".j1")) {
                    int resultOP = JOptionPane.showConfirmDialog(null, tr.get(ID + ".confirmation.message"),
                            tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
                    if (resultOP != JOptionPane.OK_OPTION) {
View Full Code Here

        ApplicationWindow aw = getApplicationWindow();
        final StatusBar bar = aw.getStatusBar();
        final ProgressMonitor pm = bar.getProgressMonitor();

        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle(tr.get(ID + ".fileDialog"));
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int res = fc.showOpenDialog(aw.getControl());
        if (res != JFileChooser.APPROVE_OPTION) {
            bar.setMessage(tr.get(ID + ".noFileSelected"));
            return;
        }
        file = fc.getSelectedFile();
        if (!file.isDirectory()) {
            int resultOP = JOptionPane.showConfirmDialog(null, tr.get(ID + ".confirmation.message"),
                    tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
            if (resultOP != JOptionPane.OK_OPTION) {
                return;
View Full Code Here

    protected void doOnce() {
        ApplicationWindow aw = getApplicationWindow();
        final StatusBar bar = aw.getStatusBar();
        ProgressMonitor pm = bar.getProgressMonitor();

        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle(tr.get(ID + ".fileDialog"));
        int res = fc.showSaveDialog(aw.getControl());
        if (res != JFileChooser.APPROVE_OPTION) {
            bar.setMessage(tr.get(ID + ".noFileSelected"));
            return;
        }
        final File f = fc.getSelectedFile();

        pm.taskStarted(tr.get(ID + ".startTask"), -1);

        MySwingWorker sw = new MySwingWorker(ID) {
View Full Code Here

        ApplicationWindow aw = getApplicationWindow();
        final StatusBar bar = aw.getStatusBar();
        final ProgressMonitor pm = bar.getProgressMonitor();

        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle(tr.get(ID + ".fileDialog"));
        int res = fc.showOpenDialog(aw.getControl());
        if (res != JFileChooser.APPROVE_OPTION) {
            bar.setMessage(tr.get(ID + ".noFileSelected"));
            return;
        }
        file = fc.getSelectedFile();
        if (!file.getName().endsWith(".xml")) {
            int resultOP = JOptionPane.showConfirmDialog(null, tr.get(ID + ".confirmation.message"),
                    tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
            if (resultOP != JOptionPane.OK_OPTION) {
                return;
View Full Code Here

    while (!file.canRead()) {
      // It doesn't exist. Figure it out from the user.
      JOptionPane.showMessageDialog(parent,
        StringUtil.format(Strings.get("fileLibraryMissingError"),
          file.getName()));
      JFileChooser chooser = createChooser();
      chooser.setFileFilter(filter);
      chooser.setDialogTitle(StringUtil.format(Strings.get("fileLibraryMissingTitle"), file.getName()));
      int action = chooser.showDialog(parent, Strings.get("fileLibraryMissingButton"));
      if (action != JFileChooser.APPROVE_OPTION) {
        throw new LoaderException(Strings.get("fileLoadCanceledError"));
      }
      file = chooser.getSelectedFile();
    }
    return file;
  }
View Full Code Here

    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

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.