Results 1 to 4 of 4

Thread: FileFilter

  1. #1
    nonabhai is offline Member
    Join Date
    Mar 2010
    Posts
    20
    Rep Power
    0

    Question FileFilter

    Hey, I created a filefilter for jfilechooser to show "jpg" files only
    I did this code:

    public boolean accept(File f) {
    String s =f.getName();
    return s.toLowerCase().endsWith(".jpg");
    }
    public String getDescription()
    { return "jpg image files"; }
    };


    The problem is that now jfilechooser is showing "jpg" files only :D.
    I mean its not showing Folders as well, I want to show folders also. Plz help...:confused:

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,407
    Rep Power
    20

    Default

    Java Code:
    return s.toLowerCase().endsWith(".jpg") || f.isDirectory();
    In future, please use the code tags and not the italic tags to postcode.

    db

  3. #3
    nonabhai is offline Member
    Join Date
    Mar 2010
    Posts
    20
    Rep Power
    0

    Default

    Thanks db for Solution and advise.

  4. #4
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •