Here you can find the source of setSelectedFile(JFileChooser chooser, File file)
Parameter | Description |
---|---|
chooser | a parameter |
file | a parameter |
public static void setSelectedFile(JFileChooser chooser, File file)
//package com.java2s; //License from project: Apache License import java.io.File; import javax.swing.JFileChooser; public class Main { /**//from w ww . j av a 2s. c om * Set starting dir and file for a chooser. * chooser.setSelectedFile doesn't work correctly when given a directory. * * @param chooser * @param file */ public static void setSelectedFile(JFileChooser chooser, File file) { if (file.isDirectory()) chooser.setCurrentDirectory(file); else chooser.setSelectedFile(file); } }