Example usage for javax.swing JFileChooser SELECTED_FILES_CHANGED_PROPERTY

List of usage examples for javax.swing JFileChooser SELECTED_FILES_CHANGED_PROPERTY

Introduction

In this page you can find the example usage for javax.swing JFileChooser SELECTED_FILES_CHANGED_PROPERTY.

Prototype

String SELECTED_FILES_CHANGED_PROPERTY

To view the source code for javax.swing JFileChooser SELECTED_FILES_CHANGED_PROPERTY.

Click Source Link

Document

Identifies change in user's multiple-file selection.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JFileChooser chooser = new JFileChooser();

    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (JFileChooser.SELECTED_FILES_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File[] oldFiles = (File[]) evt.getOldValue();
                File[] newFiles = (File[]) evt.getNewValue();

                // Get list of selected files
                File[] files = chooser.getSelectedFiles();
            }// www .  ja  va  2  s  .co m
        }
    });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    final JFileChooser chooser = new JFileChooser();

    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (JFileChooser.SELECTED_FILES_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File oldDir = (File) evt.getOldValue();
                File newDir = (File) evt.getNewValue();

                File curDir = chooser.getCurrentDirectory();
            }//from   w  w  w .  j ava 2  s . c om
        }
    });
}

From source file:Main.java

public static void main(String[] argv) {

    JFileChooser chooser = new JFileChooser();

    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File oldFile = (File) evt.getOldValue();
                File newFile = (File) evt.getNewValue();

                System.out.println(oldFile);
                System.out.println(newFile);
                System.out.println(chooser.getSelectedFile());
            } else if (JFileChooser.SELECTED_FILES_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File[] oldFiles = (File[]) evt.getOldValue();
                File[] newFiles = (File[]) evt.getNewValue();

                Arrays.toString(oldFiles);
                Arrays.toString(newFiles);
                File[] files = chooser.getSelectedFiles();
                Arrays.toString(files);
            }// w  w w . j  av a2  s  . c  o  m
        }
    });

    chooser.setVisible(true);

}

From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java

/**
 * Reacts to property fired by the table.
 * //from   w ww  .  java2 s  . c  o m
 * @see PropertyChangeListener#propertyChange(PropertyChangeEvent)
 */
public void propertyChange(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();

    if (FileSelectionTable.ADD_PROPERTY.equals(name)) {
        showLocationDialog();
    } else if (FileSelectionTable.REMOVE_PROPERTY.equals(name)) {
        int n = handleFilesSelection(chooser.getSelectedFiles());
        table.allowAddition(n > 0);
        importButton.setEnabled(table.hasFilesToImport());
    } else if (JFileChooser.SELECTED_FILES_CHANGED_PROPERTY.equals(name)) {
        int n = handleFilesSelection(chooser.getSelectedFiles());
        table.allowAddition(n > 0);
    } else if (NumericalTextField.TEXT_UPDATED_PROPERTY.equals(name)) {
        if (partialName.isSelected()) {
            Integer number = (Integer) numberOfFolders.getValueAsNumber();
            if (number != null && number >= 0)
                table.applyToAll();
        }
    } else if (SelectionWizard.SELECTED_ITEMS_PROPERTY.equals(name)) {
        Map m = (Map) evt.getNewValue();
        if (m == null || m.size() != 1)
            return;
        Set set = m.entrySet();
        Entry entry;
        Iterator i = set.iterator();
        Class type;
        while (i.hasNext()) {
            entry = (Entry) i.next();
            type = (Class) entry.getKey();
            if (TagAnnotationData.class.getName().equals(type.getName()))
                handleTagsSelection((Collection<TagAnnotationData>) entry.getValue());
        }
    } else if (ImportDialog.PROPERTY_GROUP_CHANGED.equals(name)
            || ImportDialog.REFRESH_LOCATION_PROPERTY.equals(name)
            || ImportDialog.CREATE_OBJECT_PROPERTY.equals(name)) {
        firePropertyChange(name, evt.getOldValue(), evt.getNewValue());
    } else if (LocationDialog.ADD_TO_QUEUE_PROPERTY.equals(name)) {
        Object src = evt.getSource();
        if (src != detachedDialog) {
            addImageJFiles(null, null);
        }
    }
}