1. /*
  2. * @(#)FileView.java 1.14 00/02/02
  3. *
  4. * Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.swing.filechooser;
  11. import java.io.File;
  12. import javax.swing.*;
  13. /**
  14. * FileView defines an abstract class that can be implemented to
  15. * provide the filechooser with ui information for a File.
  16. * Each L&F JFileChooserUI object implements this class to pass
  17. * back the correct icons and type descriptions specific to
  18. * that L&F. For example, the Windows L&F returns the generic Windows
  19. * icons for directories and generic files.
  20. * Additionally, you may want to provide your own FileView to
  21. * JFileChooser to return different icons or additional information
  22. * using {@link javax.swing.JFileChooser#setFileView}.
  23. *
  24. * <p>
  25. *
  26. * JFileChooser first looks to see if there is a user defined FileView,
  27. * if there is, it gets type information from there first. If FileView
  28. * returns null for any method, JFileChooser then uses the L&F specific
  29. * view to get the information.
  30. * So, for example, if you provide a FileView class that returns an
  31. * <code>Icon</code> for JPG files, and returns <code>null</code>
  32. * icons for all other files, the UI's FileView will provide default
  33. * icons for all other files.
  34. *
  35. * <p>
  36. *
  37. * For an example implementation of a simple file filter, see
  38. * <code><i>yourSDK</i>/demo/jfc/FileChooserDemo/ExampleFileView.java</code>.
  39. * For more information and examples see
  40. * <a
  41. href="http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html">How to Use File Choosers</a>,
  42. * a section in <em>The Java Tutorial</em>.
  43. *
  44. * @see javax.swing.JFileChooser
  45. *
  46. * @version 1.14 02/02/00
  47. * @author Jeff Dinkins
  48. *
  49. */
  50. public abstract class FileView {
  51. /**
  52. * The name of the file. Normally this would be simply f.getName()
  53. */
  54. public String getName(File f) {
  55. return null;
  56. };
  57. /**
  58. * A human readable description of the file. For example,
  59. * a file named jag.jpg might have a description that read:
  60. * "A JPEG image file of James Gosling's face"
  61. */
  62. public String getDescription(File f) {
  63. return null;
  64. }
  65. /**
  66. * A human readable description of the type of the file. For
  67. * example, a jpg file might have a type description of:
  68. * "A JPEG Compressed Image File"
  69. */
  70. public String getTypeDescription(File f) {
  71. return null;
  72. }
  73. /**
  74. * The icon that represents this file in the JFileChooser.
  75. */
  76. public Icon getIcon(File f) {
  77. return null;
  78. }
  79. /**
  80. * Whether the directory is traversable or not. This might be
  81. * useful, for example, if you want a directory to represent
  82. * a compound document and don't want the user to descend into it.
  83. */
  84. public Boolean isTraversable(File f) {
  85. return null;
  86. }
  87. }