KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > filechooser > FileView


1 /*
2  * @(#)FileView.java 1.19 04/06/28
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.swing.filechooser;
9
10 import java.io.File JavaDoc;
11 import javax.swing.*;
12
13 /**
14  * <code>FileView</code> defines an abstract class that can be implemented
15  * to provide the filechooser with UI information for a <code>File</code>.
16  * Each L&F <code>JFileChooserUI</code> object implements this
17  * class to pass back the correct icons and type descriptions specific to
18  * that L&F. For example, the Microsoft Windows L&F returns the
19  * generic Windows icons for directories and generic files.
20  * Additionally, you may want to provide your own <code>FileView</code> to
21  * <code>JFileChooser</code> to return different icons or additional
22  * information using {@link javax.swing.JFileChooser#setFileView}.
23  *
24  * <p>
25  *
26  * <code>JFileChooser</code> first looks to see if there is a user defined
27  * <code>FileView</code>, if there is, it gets type information from
28  * there first. If <code>FileView</code> returns <code>null</code> for
29  * any method, <code>JFileChooser</code> then uses the L&F specific
30  * view to get the information.
31  * So, for example, if you provide a <code>FileView</code> class that
32  * returns an <code>Icon</code> for JPG files, and returns <code>null</code>
33  * icons for all other files, the UI's <code>FileView</code> will provide
34  * default icons for all other files.
35  *
36  * <p>
37  *
38  * For an example implementation of a simple file view, see
39  * <code><i>yourJDK</i>/demo/jfc/FileChooserDemo/ExampleFileView.java</code>.
40  * For more information and examples see
41  * <a
42  href="http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html">How to Use File Choosers</a>,
43  * a section in <em>The Java Tutorial</em>.
44  *
45  * @see javax.swing.JFileChooser
46  *
47  * @version 1.19 06/28/04
48  * @author Jeff Dinkins
49  *
50  */

51 public abstract class FileView {
52     /**
53      * The name of the file. Normally this would be simply
54      * <code>f.getName()</code>.
55      */

56     public String JavaDoc getName(File JavaDoc f) {
57     return null;
58     };
59
60     /**
61      * A human readable description of the file. For example,
62      * a file named <i>jag.jpg</i> might have a description that read:
63      * "A JPEG image file of James Gosling's face".
64      */

65     public String JavaDoc getDescription(File JavaDoc f) {
66     return null;
67     }
68
69     /**
70      * A human readable description of the type of the file. For
71      * example, a <code>jpg</code> file might have a type description of:
72      * "A JPEG Compressed Image File"
73      */

74     public String JavaDoc getTypeDescription(File JavaDoc f) {
75     return null;
76     }
77
78     /**
79      * The icon that represents this file in the <code>JFileChooser</code>.
80      */

81     public Icon getIcon(File JavaDoc f) {
82     return null;
83     }
84
85     /**
86      * Whether the directory is traversable or not. This might be
87      * useful, for example, if you want a directory to represent
88      * a compound document and don't want the user to descend into it.
89      */

90     public Boolean JavaDoc isTraversable(File JavaDoc f) {
91     return null;
92     }
93
94 }
95
Popular Tags