In the code given below, taken from the JAVA API page for class JFileChooser:
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"JPG & GIF Images", "jpg", "gif");
chooser.setFileFilter(filter);
int returnVal = chooser.showOpenDialog(parent);
if(returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose to open this file: " +
chooser.getSelectedFile().getName());
}
It is supposed to open a popup window to prompt for a file in the user's directory. May I know how we should initialize the 'parent' variable, or what values to assign to it so that this dialog window points to the user's directory?