int rVal = c.showOpenDialog(FileChooserTest.this);if(rVal == JFileChooser.CANCEL_OPTION) {
        filename.setText("You pressed cancel");
}

解决方案 »

  1.   

    It seems to me there's no direct way of knowing that.
    Indirectly:
      dlg.show();
      if(dlg.getFile() == null) { // cancel
       ...
      }Better use javax.swing.JFileChooser:
      JFileChooser fc = new JFileChooser();
      fc.setCurrentDirectory(new File("c:/"));
      fc.setMultiSelectionEnabled(true);
      if(fc.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) { // cancel
       ...
      }else {
       fc.getSelectedFiles();
       ...
      }
      

  2.   

    to helpall() 我是刚刚开始用java做项目(没办法,做项目的人就是这样),用jfilechooser能够实现保存对话框么?
      

  3.   

    可以.
    JFileChooser fc = new JFileChooser("c:/aa");
    fc.setDialogType(JFileChooser.SAVE_DIALOG);
      

  4.   

    忘了说一句,如果你在其他地方都是用awt的GUI,则最好不用JFileChooser. awt和swing不太兼容.
      

  5.   

    多谢,我的程序将来要用javawebstart部署,能否使用jfilechooser或者说必须使用FileSystemService?
      

  6.   

    当然可以了。JFileChooser fileChooser = new JFileChooser();
    int option = fileChooser.showSaveDialog(null);
      

  7.   

    请问这个文件FileSystemService 所引用的包 如何下载??谢谢!
      

  8.   

    老实说,我没有做过javawebstart部署,也没听过FileSystemService.还是请高手吧.
      

  9.   

    我已经搞定了
    jdk1.4已经直接支持,不用你单独下载webstart sdk啊