title: JFileChooser on a Button Click
body: <p>I have a button, clicking on which I want the JFileChooser to pop up. I have tried this</p>
  
  <pre><code>JButton browse= new JButton("Browse");
  add(browse);
  browse.addActionListener(new ClassBrowse());
  
  public class ClassBrowse implements ActionListener {
      public void actionPerformed(ActionEvent e) {
      int returnVal = fileChooser.showOpenDialog(this);
          if (returnVal == JFileChooser.APPROVE_OPTION) {
              File file = fileChooser.getSelectedFile();
              try {
                // return the file path 
              } catch (Exception ex) {
                System.out.println("problem accessing file"+file.getAbsolutePath());
              }
          } 
          else {
              System.out.println("File access cancelled by user.");
          }       
      }   
  }
  </code></pre>
  
  <p>Bhe above gives error <code>The method showOpenDialog(Component) in the type JFileChooser is not applicable for the arguments (ClassName.ClassBrowse)</code></p>
  
  <p>Also, I want it to return the complete file path. How do I do so ?</p>