Package javax.swing

Examples of javax.swing.JFileChooser$AccessibleJFileChooser


    add(hbox,BorderLayout.SOUTH);
   
    btnLoc.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        JFileChooser fc = new JFileChooser(location);
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int res = fc.showOpenDialog(PackagesPanel.this.installer);
        if (res==JFileChooser.APPROVE_OPTION) {
          // first choose selection
          location = fc.getSelectedFile();
          // if user entered directory but no selection, choose it instead
          if (location==null) location = fc.getCurrentDirectory();
          updateLoc();
        }
      }
    });
View Full Code Here


 
  public SharedTab(final JFrame parent) {
    super(parent);
    init();
    file_system_view = FileSystemView.getFileSystemView();
        file_chooser = new JFileChooser( file_system_view );
        file_chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        file_chooser.setMultiSelectionEnabled(true);
       
        file_chooser.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent event) {
View Full Code Here

        }
        return null;
    }

    private static JFileChooser createChooser() {
        JFileChooser chooser = new JFileChooser();
        // to prevent a deadlock (using Java6) make a copy of the File
        chooser.setCurrentDirectory(new File(CurrentPathProvider.currentPathProvider.getCurrentPath().getAbsolutePath()));
        chooser.setFileFilter(new FileFilter() {
            @Override
            public boolean accept(File f) {
                if (f.isDirectory())
                    return true;
                return f.getName().endsWith(JAVA_3D_FILE_EXT);
View Full Code Here

    private void doWork() {
     
        initComponents();
       
        file_system_view = FileSystemView.getFileSystemView();
        file_chooser = new JFileChooser( file_system_view );
        file_chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        file_chooser.setMultiSelectionEnabled(true);
       
        chosen_folders = new ChosenFolders();
        List<File> shared_folders = null;
View Full Code Here

            // Here's the code that brings up the dialog.
            button.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    // Set up the file chooser.
                    if (fileChooser == null) {
                        fileChooser = new JFileChooser();
                        // Add a custom file filter and disable the default
                        // (Accept All) file filter.
                        fileChooser.addChoosableFileFilter(new ImageFileFilter());
                        fileChooser.setAcceptAllFileFilterUsed(false);
                        // Add the preview pane.
View Full Code Here

    }

    /** Do a previously declared action */
    public void doAction(Object action) {
        if (action.equals("Load file")) {
            JFileChooser chooser = new JFileChooser();
            chooser.setFileFilter(new FileFilter() {
                public boolean accept(File f) {
                    if (f.isDirectory()) return true;
                    String name = f.getName();
                    return name.toLowerCase().endsWith(".xyz");
                }
                public String getDescription() {
                    return "XYZ result files (*.xyz)";
                }
            });
            int ret = chooser.showOpenDialog(null);
            if (ret == JFileChooser.APPROVE_OPTION) {
                try {
          load(chooser.getSelectedFile());
        } catch (IOException e) {
          JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), "Can't load "+chooser.getSelectedFile(),JOptionPane.ERROR_MESSAGE);
          return;
        }
            }
        }
        super.doAction(action);
View Full Code Here

     *            OPEN or SAVE action.
     * @return a new FileChooser initialised with currentDirectory and all
     *         plugin filters
     */
    public void createFileChooser(int action) {
        JFileChooser fileChooser = new JFileChooser(getPath());

        if (action == Plugin.SAVE) {
            saveFileChooser = fileChooser;

        } else if (action == Plugin.OPEN){
            openFileChooser = fileChooser;

        } else if (action == Plugin.EXPORT){
            exportFileChooser = fileChooser;
        }

        javax.swing.filechooser.FileFilter firstFilter = null;
        for (int i = 0; i < Run.plugins.size(); ++i) {
            Plugin p = (Plugin) Run.plugins.get(i);
            javax.swing.filechooser.FileFilter[] fft = p.getFileFilters(action);
            if (fft == null) {
                continue;
            }
            for (int j = 0; j < fft.length; ++j) {
                fileChooser.addChoosableFileFilter(fft[j]);
                if (firstFilter == null) {
                    firstFilter = fft[j];
                }
            }
        }
        fileChooser.setAcceptAllFileFilterUsed(false); // don't want all file
        // filters in aggregate
        AggregateFileFilter agf = null;
        if (action == Plugin.OPEN) {
            agf = new AggregateFileFilter(fileChooser.getChoosableFileFilters());
            fileChooser.addChoosableFileFilter(agf);
        }
        // Add an accessory panel
        fileChooser.setAccessory(new FileChooserAccessory(action));

        fileChooser.setMultiSelectionEnabled(action == Plugin.OPEN);
        fileChooser.setAcceptAllFileFilterUsed(true);
        if (firstFilter != null) {
            fileChooser.setFileFilter(agf != null ? agf : firstFilter);
        }
    }
View Full Code Here

        }
    }

    protected File[] getFilesFromDialog(int action) {
        String dialogText;
        JFileChooser fileChooser;
        if (action == Plugin.SAVE) {
            dialogText = resources.getStringValue("saveDialogText");
            fileChooser = saveFileChooser;

        } else if (action == Plugin.EXPORT) {
            dialogText = resources.getStringValue("exportDialogText");
            fileChooser = exportFileChooser;

        } else {
            dialogText = resources.getStringValue("openDialogText");
            fileChooser = openFileChooser;
        }

        fileChooser.setCurrentDirectory(getPath());

        if ((fileChooser.getAccessory() != null) && (fileChooser.getAccessory() instanceof FileChooserAccessory)){
            ((FileChooserAccessory)fileChooser.getAccessory()).updateFileChooserAccessory();
        }

        int result = fileChooser.showDialog(owner, dialogText);
        if (result != JFileChooser.APPROVE_OPTION) {
            return null;
        }
        CurrentPathProvider.currentPathProvider.setCurrentPath(fileChooser.getCurrentDirectory());


        FileFilter currentFileFilter =  fileChooser.getFileFilter();
        if (currentFileFilter instanceof AggregateFileFilter) {
            currentFileFilter = ((AggregateFileFilter) currentFileFilter).getFilterForFile(getOwner(), fileChooser
                    .getSelectedFile());
            if (currentFileFilter == null) {
                return null;
            }
        }

        if (action == Plugin.SAVE) {
            currentSaveFileFilter = currentFileFilter;
        } else if (action == Plugin.EXPORT) {
            currentExportFileFilter = currentFileFilter;
        } else {
            currentOpenFileFilter = currentFileFilter;
        }


        File[] ret;
        if (fileChooser.isMultiSelectionEnabled()) {
            ret = fileChooser.getSelectedFiles();
        } else {
            ret = new File[1];
            String fileName = fileChooser.getSelectedFile().getParent() + File.separator +  fileChooser.getSelectedFile().getName();

            // Add file extention relarging the current file filter
            if ( fileChooser.getFileFilter() instanceof MenuResourceBundle.FileFilter){
                String fileFilterExtension =  ((MenuResourceBundle.FileFilter)fileChooser.getFileFilter()).getExtension();
                if (fileName.indexOf(".") != -1) {
                    String fileExtention = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());

                    if (!fileExtention.equalsIgnoreCase(fileFilterExtension)){
                        fileName += "." + fileFilterExtension ;
View Full Code Here

        bg.add(rbResize);
        bChoose.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                // Set up the file chooser.
                if (fileChooser == null) {
                    fileChooser = new JFileChooser();
                    // Add a custom file filter and disable the default
                    // (Accept All) file filter.
                    fileChooser.addChoosableFileFilter(new ImageMapper.ImageFileFilter());
                    fileChooser.setAcceptAllFileFilterUsed(false);
                    // Add the preview pane.
View Full Code Here

                    }
                    if(Loader.class.isAssignableFrom(c)){
                        Class<? extends Loader> cl=c.asSubclass(Loader.class);
                        classes.put(extDescClass[i][0],cl);
                        if(chooser==null){
                            chooser=new JFileChooser();
                            chooser.setCurrentDirectory(jsynoptic.ui.JSynoptic.gui.getPath());
                            chooser.setAcceptAllFileFilterUsed(false); // don't want all
                            filters=new HashMap<FileFilter, String>();
                        }
                        final int r=i;
View Full Code Here

TOP

Related Classes of javax.swing.JFileChooser$AccessibleJFileChooser

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.