Question

I'm using this tutorial to add a File Chooser in a Netbeans project: https://netbeans.org/kb/docs/java/gui-filechooser.html

I'm not using the project that they set up, but have followed the File Chooser part of the tutorial exactly as written.

I just can't get the FileFilter to work though. I get the following error on this line in initComponents() :

FileChooser.setFileFilter(MyCustomFilter());

It throws the error:

error: cannot find symbol FileChooser.setFileFilter(MyCustomFilter()); symbol: method MyCustomFilter() location: class frmMain

I have tried placing the code for the MyCustomFilter class under the imports at the top (as suggested in the tutorial) and at various other points in the code, but with no success.

Where exactly should this code go? Any other reasons why I am getting this error? To reiterate, I am following the tutorial from the "Adding the File Chooser" section downwards and copying and pasting the code.

Was it helpful?

Solution

Call the constructor using the new keyword

fileChooser.setFileFilter(new MyCustomFilter());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top