DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Hybrid View

  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.



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links