Java Swing Tutorial - Java JFileChooser SELECTED _FILES _CHANGED _PROPERTY


JFileChooser.SELECTED_FILES_CHANGED_PROPERTY has the following syntax.

public static final String SELECTED_FILES_CHANGED_PROPERTY


In the following code shows how to use JFileChooser.SELECTED_FILES_CHANGED_PROPERTY field.

//from   www.  j a  v a 2s .  c  om
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import javax.swing.JFileChooser;

public class Main {
  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();