• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem with filefilter for jfilechooser

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello all,
I'm currently having a problem with using the FileFilter object to apply a choosable file filter to the JFileChooser. Unfortunately I don't have access to my code right this minute but I was hoping that someone might be able to point me in the right direction of where to start looking for the problem.

Currently I have a JFileChooser used to browse files. I need several file filters, however, I can't statically code them, e.g., code a seperate class for each and etc., What I've done extended the FileFilter class and added a method to accept an array of extensions and a filter description.

In the constructor for my panel that displays my file browser, I iterate through a 2-d array that contains a file description tied to an array of extensions. I then create new instances of my FileFilter class based on this array.

Now, when I launch the JFileChooser, I get my list of filters in the drop down and the first time I select a filter it correctly filters the contents of the directory. Unfortunately, if I choose a different filter and go back .. ok clarification:

I have 4 filters, A,B,C,D, (A representing the All Files filter). Say I'm looking at a directory that only has files of type B and then some misc. files that only show up in the All Files filter. The first time I look at that directory and choose B, it will correctly filter the files however, if I then select a different filter and go back to B, B now displays all files in the directory. Now, If I originally select a filter that doesn't apply to any files in the current directory, say filter C, this behavior doesn't happen, e.g., Select C, no files displayed, select A, all files displayed, select C, no files displayed.

If I close the file browser and then launch it again (note, not closing the panel that contains the button to launch the file browser, just the browser) this behavior persists.

I'm stumped - any input would be greatly appreciated.
Thanks!
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would greatly help if you post some actual code. If you have some webspace available, providing screen shots would be nice as well. You can give links (or put the image in your post) with UBB tags. Also, you will probably get more helful responses at the GUI forum.

Keep Coding!

Layne
 
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Could you please give us the code (or maybe error message) for your problem so we can help you?

thanks
daniel
 
c moses
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your replies gentleman, unfortunately, and I certainly understand that this definetly limits ones ability to comment on my question, but I just can't post the code - I'm not currently at that location and the machine the code is located on is not connnected to a network... - I understand that people won't be able to offer me a solution, just looking for some suggestions about where to start looking for the problem.

I don't actually receive any error message it really is that it's like the filter just stops working after being selected once and any filter that has extensions present in that directory defaults to all files.

thanks much and thanks for any comments
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic