Guest User

Untitled

a guest
Jan 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. package components;
  2.  
  3. import java.io.File;
  4. import javax.swing.*;
  5. import javax.swing.filechooser.*;
  6.  
  7. /* ImageFilter.java is used by FileChooserDemo2.java. */
  8. public class FileFilter extends FileFilter {
  9.  
  10. //Accept all directories and txt files.
  11. public boolean accept(File f) {
  12. if (f.isDirectory()) {
  13. return true;
  14. }
  15.  
  16. String extension = Utils.getExtension(f);
  17. if (extension != null) {
  18. if (extension.equals(Utils.txt)) {
  19. return true;
  20. } else {
  21. return false;
  22. }
  23. }
  24.  
  25. return false;
  26. }
  27.  
  28. //The description of this filter
  29. public String getDescription() {
  30. return "Just A Text File";
  31. }
  32. }
Add Comment
Please, Sign In to add comment