3

I have created JFileChooser and I need to add search functionality when a user browse for a particular folder to locate a certain file with ease such the JFilechooser should have a text field where user can type and filter other files in a given directory. How can I achieve this in java?

Here is My sample code that implements basic file browsing.

  JFileChooser chooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter("Excell File Only", "csv");
        chooser.setFileFilter(filter);
        int returnVal = chooser.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            if (chooser.getSelectedFile() != null) {
                path.setText(chooser.getSelectedFile().getName());



            }}
Alex
  • 4,457
  • 2
  • 20
  • 59
MorganM
  • 195
  • 1
  • 1
  • 10
  • 1
    Not easily, for an example of the insanity, check out [this](http://stackoverflow.com/questions/25538213/change-the-location-of-the-accessory-component-in-a-filechooser/25538945#25538945) – MadProgrammer Nov 25 '14 at 10:22
  • Ey MorganM, something like this could help : http://stackoverflow.com/questions/13517770/jfilechooser-filters? – Victor Jun 18 '15 at 15:51

0 Answers0