tags:

views:

43

answers:

1

I'm looking for a way to filter files in an "Open" window. I'm using NetBeans IDE 6.5. I did some research, and this is what i came up with, but for some reason it's not working.

//global variable protected static FileFilter myfilter;

//in declaration of variables fchoLoad.setFileFilter(myfilter);

//inside main myfilter = .... (i actually delted this part by accident, i need to filter only .fwd files. can anybody tell me what goes here?)

A: 

If I understand it correctly, you want to create your own file chooser and be able to filter just some files (.fwd in your case). I guess this is more general Java question (not only NetBeans) and I suggest reading this tutorial

Anyway, your "myfilter" should look like this:

myfilter = new FileFilter() {

            public boolean accept(File f) {
                return f.getName().toLowerCase().endsWith(".fwd")
                        || f.isDirectory();
            }

            public String getDescription() {
                return "FWD Files"; //type any description you want to display
            }
        };

Hope that helps

Vafliik