src/share/classes/javax/swing/filechooser/FileView.java

Print this page




  40  * information using {@link javax.swing.JFileChooser#setFileView}.
  41  *
  42  * <p>
  43  *
  44  * <code>JFileChooser</code> first looks to see if there is a user defined
  45  * <code>FileView</code>, if there is, it gets type information from
  46  * there first. If <code>FileView</code> returns <code>null</code> for
  47  * any method, <code>JFileChooser</code> then uses the L&amp;F specific
  48  * view to get the information.
  49  * So, for example, if you provide a <code>FileView</code> class that
  50  * returns an <code>Icon</code> for JPG files, and returns <code>null</code>
  51  * icons for all other files, the UI's <code>FileView</code> will provide
  52  * default icons for all other files.
  53  *
  54  * <p>
  55  *
  56  * For an example implementation of a simple file view, see
  57  * <code><i>yourJDK</i>/demo/jfc/FileChooserDemo/ExampleFileView.java</code>.
  58  * For more information and examples see
  59  * <a
  60  href="http://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html">How to Use File Choosers</a>,
  61  * a section in <em>The Java Tutorial</em>.
  62  *
  63  * @see javax.swing.JFileChooser
  64  *
  65  * @author Jeff Dinkins
  66  *
  67  */
  68 public abstract class FileView {
  69     /**
  70      * The name of the file. Normally this would be simply
  71      * <code>f.getName()</code>.
  72      */
  73     public String getName(File f) {
  74         return null;
  75     };
  76 
  77     /**
  78      * A human readable description of the file. For example,
  79      * a file named <i>jag.jpg</i> might have a description that read:
  80      * "A JPEG image file of James Gosling's face".




  40  * information using {@link javax.swing.JFileChooser#setFileView}.
  41  *
  42  * <p>
  43  *
  44  * <code>JFileChooser</code> first looks to see if there is a user defined
  45  * <code>FileView</code>, if there is, it gets type information from
  46  * there first. If <code>FileView</code> returns <code>null</code> for
  47  * any method, <code>JFileChooser</code> then uses the L&amp;F specific
  48  * view to get the information.
  49  * So, for example, if you provide a <code>FileView</code> class that
  50  * returns an <code>Icon</code> for JPG files, and returns <code>null</code>
  51  * icons for all other files, the UI's <code>FileView</code> will provide
  52  * default icons for all other files.
  53  *
  54  * <p>
  55  *
  56  * For an example implementation of a simple file view, see
  57  * <code><i>yourJDK</i>/demo/jfc/FileChooserDemo/ExampleFileView.java</code>.
  58  * For more information and examples see
  59  * <a
  60  href="https://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html">How to Use File Choosers</a>,
  61  * a section in <em>The Java Tutorial</em>.
  62  *
  63  * @see javax.swing.JFileChooser
  64  *
  65  * @author Jeff Dinkins
  66  *
  67  */
  68 public abstract class FileView {
  69     /**
  70      * The name of the file. Normally this would be simply
  71      * <code>f.getName()</code>.
  72      */
  73     public String getName(File f) {
  74         return null;
  75     };
  76 
  77     /**
  78      * A human readable description of the file. For example,
  79      * a file named <i>jag.jpg</i> might have a description that read:
  80      * "A JPEG image file of James Gosling's face".