FileFilters in Java


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: FileFilters in Java

  1. #1
    Simon Birch Guest

    FileFilters in Java


    Is there anyway to set what files are filtered in a JFileChooser dialog box
    in java? I've got a line that goes:

    fileChooser.setFileFilter(filter);

    but I need to know really how to extend the FileFilter class to make it useful!
    I want to be able to just display *.JPW files and set the name of this filter
    to Java Person Files(s), so if anyone can help, please mail me ;-).

    + Checkout http://www.birches.pwp.blueyonder.co.uk/html/index.htm if you
    want to play frogger or Pontoon and tell me what you think.

  2. #2
    Rajkamal Gopinath Guest

    Re: FileFilters in Java



    Hi

    class MyFiles implements FileFilter
    {
    public boolean accept(File f)
    {
    if(f.getName().endsWith(".jpw"))
    return true;
    return false;
    }
    public String getDescription()
    {
    return "Your Files (*.jpw)";
    }

    }

    Now set this instance as filefilter for filechooser

    Regards

    Rajkamal


    "Simon Birch" <the_dougle@hotmail.com> wrote:


    >
    >Is there anyway to set what files are filtered in a JFileChooser dialog

    box
    >in java? I've got a line that goes:
    >
    > fileChooser.setFileFilter(filter);
    >
    >but I need to know really how to extend the FileFilter class to make it

    useful!
    > I want to be able to just display *.JPW files and set the name of this

    filter
    >to Java Person Files(s), so if anyone can help, please mail me ;-).
    >
    >+ Checkout http://www.birches.pwp.blueyonder.co.uk/html/index.htm if you
    >want to play frogger or Pontoon and tell me what you think.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center