Example usage for javax.swing JFileChooser SELECTED_FILE_CHANGED_PROPERTY

List of usage examples for javax.swing JFileChooser SELECTED_FILE_CHANGED_PROPERTY

Introduction

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

Prototype

String SELECTED_FILE_CHANGED_PROPERTY

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

Click Source Link

Document

Identifies change in user's single-file selection.

Usage

From source file:FileChooserDemo2.java

public void propertyChange(PropertyChangeEvent e) {
    boolean update = false;
    String prop = e.getPropertyName();

    // If the directory changed, don't show an image.
    if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(prop)) {
        file = null;//from  ww  w.j  a  v a  2s.  co m
        update = true;

        // If a file became selected, find out which one.
    } else if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(prop)) {
        file = (File) e.getNewValue();
        update = true;
    }

    // Update the preview accordingly.
    if (update) {
        thumbnail = null;
        if (isShowing()) {
            loadImage();
            repaint();
        }
    }
}

From source file:org.datacleaner.widgets.OpenAnalysisJobFileChooserAccessory.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
        _file = _fileChooser.getSelectedFileObject();
        if (_file != null && _file.getName().getBaseName().endsWith(FileFilters.ANALYSIS_XML.getExtension())) {
            showFileInformation();//from  www .j  a  va  2  s  .c  o m
        } else {
            setVisible(false);
        }
    }
}