Container: addPropertyChangeListener(PropertyChangeListener listener) : Container « java.awt « Java by API






Container: addPropertyChangeListener(PropertyChangeListener listener)

  


import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;

import javax.swing.JFileChooser;

public class Main {
  public static void main(String[] argv) throws Exception {
    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();

          
          File curFile = chooser.getSelectedFile();
        }       
      }
    });
  }
}

   
    
  








Related examples in the same category

1.Container: getComponentCount()
2.Container: getFocusTraversalPolicy()
3.Container: setFocusTraversalPolicy(FocusTraversalPolicy policy)