JFileChooser
- class javax.swing..JFileChooser public class JFileChooser extends JComponent implements Accessible Tree:java.lang.Object - java.awt.Component - java.awt.Container - javax.swing.JComponent - javax.swing.JFileChooser JFileChooser provides a simple mechanism for the user to chooser a file. The following pops up a file chooser in the users home directory that only sees .jpg and .gif images: JFileChooser chooser = new JFileChooser(); // Note: source for ExtensionFileFilter can be found in the SwingSet demo ExtensionFileFilter filter = new ExtensionFileFilter(); filter.addExtension("jpg"); filter.addExtension("gif"); filter.setDescription("JPG & GIF Images"); 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()); } JFileChooser() - Constructor for class javax.swing.JFileChooser public JFileChooser () Creates a JFileChooser pointing to the user's home directory. JFileChooser(File) - Constructor for class javax.swing.JFileChooser public JFileChooser (File currentDirectory) Creates a JFileChooser using the given File as the path. Passing in a null file causes the file chooser to point to the users's home directory.Parameters: directory - a File object specifying the path to a file or directory JFileChooser(File, FileSystemView) - Constructor for class javax.swing.JFileChooser public JFileChooser (File currentDirectory, FileSystemView fsv) Creates a JFileChooser using the given current directory and FileSystemView JFileChooser(FileSystemView) - Constructor for class javax.swing.JFileChooser public JFileChooser (FileSystemView fsv) Creates a JFileChooser using the given FileSystemView JFileChooser(String) - Constructor for class javax.swing.JFileChooser public JFileChooser (String currentDirectoryPath) Creates a JFileChooser using the given path. Passing in a null string causes the file chooser to point to the users home directory.Parameters: path - a String giving the path to a file or directory JFileChooser(String, FileSystemView) - Constructor for class javax.swing.JFileChooser public JFileChooser (String currentDirectoryPath, FileSystemView fsv) Creates a JFileChooser using the given current directory path and FileSystemView | ||||
Search Dictionary:
