Revision as of 06:57, 4 December 2010 by Han84 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
/**
 * Display file open dialog easily.
 */
public static java.io.File guiOpenFile(java.awt.Component caller, String homeDirectory) {
	javax.swing.JFileChooser fc = new javax.swing.JFileChooser();
	fc.setSelectedFile(new java.io.File(homeDirectory));
	int returnVal = fc.showOpenDialog(caller);
	if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
		return fc.getSelectedFile();
	} else {
		return null;
	}
}
 
public static java.io.File guiOpenFile(java.awt.Component caller) {
	return Ts.guiOpenFile(caller, ".");
}


Back to JavaHowTo

Alumni Liaison

Have a piece of advice for Purdue students? Share it through Rhea!

Alumni Liaison