Example usage for javax.swing JFileChooser setSelectedFiles

List of usage examples for javax.swing JFileChooser setSelectedFiles

Introduction

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

Prototype

@BeanProperty(description = "The list of selected files if the chooser is in multiple selection mode.")
public void setSelectedFiles(File[] selectedFiles) 

Source Link

Document

Sets the list of selected files if the file chooser is set to allow multiple selection.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JFileChooser chooser = new JFileChooser();
    File f = new File(new File("filename.txt").getCanonicalPath());

    chooser.setSelectedFiles(new File[] { f });
    chooser.showDialog(new JFrame(""), null);
    File curFile = chooser.getSelectedFile();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JFileChooser chooser = new JFileChooser();
    File f = new File(new File("filename.txt").getCanonicalPath());

    chooser.setSelectedFiles(new File[] { f });

    chooser.showOpenDialog(null);/*from www .ja  v a  2  s.  c  om*/
    File curFile = chooser.getSelectedFile();
}