Here you can find the source of chooseFile(JFileChooser fc, Component parent)
public static File chooseFile(JFileChooser fc, Component parent)
//package com.java2s; import java.awt.Component; import java.io.File; import javax.swing.JFileChooser; public class Main { public static File chooseFile(JFileChooser fc, Component parent) { int returnVal = fc.showOpenDialog(parent); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); return file; } else/*from ww w.j av a 2 s . c om*/ return null; } }