JMenuItem mntmLoad = new JMenuItem("Load");
        mntmLoad.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                JFileChooser chooser = new JFileChooser();
                chooser.setMultiSelectionEnabled(true);
                int option = chooser.showOpenDialog(testgui.this);
                if (option == JFileChooser.APPROVE_OPTION) {
                  File[] sf = chooser.getSelectedFiles();
                  String filelist = "nothing";
                  if (sf.length > 0) filelist = sf[0].getName();
                  for (int i = 1; i < sf.length; i++) {
                    filelist += ", " + sf[i].getName();
                  }
                  statusbar.setText("You chose " + filelist);
                }
                else {
                  statusbar.setText("You canceled.");
                }
                }
        });
        mnFile.add(mntmLoad);

the compiler show error on this line(The method showOpenDialog(Component) in the type JFileChooser is not applicable for the arguments (testgui))

int option = chooser.showOpenDialog(testgui.this);

any idea?

Edited 2 Years Ago by sing1006

You didn't post the declaration of testgui, but apparently it's not a subclass of Component. The ".this" is even more mysterious.

Edited 2 Years Ago by JamesCherrill

This question has already been answered. Start a new discussion instead.