![]() |
The Java Developers Almanac 1.4 |
|
e893. Getting the File-Type Name of a FileFiles and directories have a type, usually based on their extension. This example retrieves the name of the file type. Examples of file-type names include Java Source and Shortcut. This name is displayed with the filename in a file chooser dialog. JFileChooser chooser = new JFileChooser();
// Create a File instance of the file
File file = new File("filename.txt");
// Get the file type name
String fileTypeName = chooser.getTypeDescription(file);
// Text Document
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 e892. Getting and Setting the Selected File of a JFileChooser Dialog e894. Copying the Filename Path from a JFileChooser Dialog to the Clipboard
© 2002 Addison-Wesley. |