FileDialog dlg = new FileDialog( this, "登録", FileDialog.LOAD );
            dlg.show();
            String filename = dlg.getDirectory();
            String file = dlg.getFile();我这样写在程序里,可以弹出一个打开文件的对话框,但现在的问题是,只能一个一个文件的选择打开,请问怎么可以一次性的选择多个文件打开呢?谢谢了

解决方案 »

  1.   

    再java 中怎么解决阿
    谢谢大家了阿
      

  2.   

    public class FileDialog
    extends DialogThe FileDialog class displays a dialog window from which the user can select a file.
                                                                             
    Since it is a modal dialog, when the application calls its show method to display the dialog, it blocks the rest of the application until the user has chosen a file.
      

  3.   

    可以用JFileChooser,
    他有一个方法public File[] getSelectedFiles()满足你的要求,
    而且还可以过滤文件类型,功能很强.
      

  4.   

    给你做了个例子 :package iotest;import java.io.*;
    import javax.swing.*;public class JFileTyper {
    public static void main(String[] args) {
    JFileChooser fc = new JFileChooser();
    // fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fc.setMultiSelectionEnabled(true);
    int result = fc.showOpenDialog(new JFrame());
    if (result == JFileChooser.APPROVE_OPTION) {
    // try {
    File[] f = fc.getSelectedFiles();
    if (f != null) { 
    for (int i=0;i<f.length;i++) {
    System.out.println(f[i].getName());
              }
    }
    }
    }
    }运行通过
      

  5.   

    谢谢楼上的兄弟了
      
    各位朋友,JFileChooser  我试过了,确实可以多选,但是在苹果机上的风格变了阿,请问一下  FileDialog 就不可以有 JFileChooser   的 功能么(多选功能)谢谢大家了分一定补加100
      

  6.   

    风格你可以通过setLookAndFee设置。
    FileDialog应该也可以实现的,不过本身没有这个功能,只能自己扩展实现