急,谢谢啦

解决方案 »

  1.   

    fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
      

  2.   

    int select;
        JFileChooser fileChooser = new JFileChooser();  //文件选择对话框
        select = fileChooser.showOpenDialog(this);
        if(select==JFileChooser.APPROVE_OPTION)
        { String filePath = fileChooser.getSelectedFile().getPath();
          接下来想干嘛就看你了;
        }
      

  3.   

    加点注释给新手
        JFileChooser fileChooser = new JFileChooser();  //文件选择对话框实例化
        int select = fileChooser.showOpenDialog(this);  //使用“打开”对话框,类似的还有“保存”,“确认”对话框,select是你点哪个按钮
        if(select==JFileChooser.APPROVE_OPTION)  //如果点“是”,则APPROVE_OPTION是JFileChooser的静态变量,int型
        { String filePath = fileChooser.getSelectedFile().getPath();  //得到选择的文件或文件夹路径,程序里文件夹也是file类
          接下来想干嘛就看你了;
        }