![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e892. Getting and Setting the Selected File of a JFileChooser DialogWhen setting the selected file, the file chooser dialog automatically sets the current directory.JFileChooser chooser = new JFileChooser(); // Set the current directory to the application's current directory try { // Create a File object containing the canonical path of the // desired file File f = new File(new File("filename.txt").getCanonicalPath()); // Set the selected file chooser.setSelectedFile(f); } catch (IOException e) { } // Show the dialog; wait until dialog is closed chooser.showOpenDialog(frame); // Get the currently selected file File curFile = chooser.getSelectedFile();
e888. Displaying Only Directories in a File Chooser Dialog e889. Adding a Filter to a File Chooser Dialog e890. Determining If the Approve or Cancel Button Was Clicked in a JFileChooser Dialog e891. Getting and Setting the Current Directory of a JFileChooser Dialog e893. Getting the File-Type Name of a File e894. Copying the Filename Path from a JFileChooser Dialog to the Clipboard
© 2002 Addison-Wesley. |