Results 1 to 3 of 3
  1. #1
    counterfox is offline Member
    Join Date
    Mar 2009
    Posts
    45
    Rep Power
    0

    Default Jfilechooser removing all file types

    Hi,

    I've created a Jfilechooser and created my own class which implements the FileFilter interface.

    Pretty much this only lets files of type ".save" which are my saved files be seen when the jfilechooser is opened. However when opened in the drop down box theres still an option to choose "all files". Is there any way to remove this so only my filter is shown?

    I've looked on the net but only found sources of the filter stuff that I've already done.

    My code for the Jfilechooser is here:

    Java Code:
    JFileChooser chooser = new JFileChooser();
    chooser.showOpenDialog(this);
    chooser.addChoosableFileFilter(new SaveFileFilter());
    The SaveFileFilter class I wrote just uses the accept and getDescription method from the interface which only lets ".save" files be shown.

    Thanks in advance

  2. #2
    rp181 is offline Member
    Join Date
    Mar 2009
    Posts
    70
    Rep Power
    0

    Default

    I'm not sure, but you may need to do chooser.setFileFilter, to only have yours in effect. This will also remove the visibility of folders, you have to explicitly handle that (check file.isDirectory()).

  3. #3
    counterfox is offline Member
    Join Date
    Mar 2009
    Posts
    45
    Rep Power
    0

    Default

    Thanks for your reply.

    I've managed to remove the all files.

    Java Code:
    fileChooser.setAcceptAllFileFilterUsed(false);
    Then I created a class based on the FileFilter interface and used that.

Similar Threads

  1. removing the last blank line from txt file
    By heartysnowy in forum New To Java
    Replies: 8
    Last Post: 12-06-2013, 01:09 PM
  2. [JFileChooser] File name to list
    By Che999po in forum AWT / Swing
    Replies: 8
    Last Post: 07-30-2010, 10:09 PM
  3. Saving to file from JFileChooser SaveDialog
    By kieran82 in forum AWT / Swing
    Replies: 2
    Last Post: 03-16-2010, 03:09 AM
  4. how to use JFileChooser to select file -> string
    By gezzel in forum AWT / Swing
    Replies: 15
    Last Post: 10-23-2008, 05:34 AM
  5. how to use JFileChooser to select file -> string
    By gezzel in forum New To Java
    Replies: 9
    Last Post: 09-18-2008, 09:45 PM

Posting Permissions

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