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