Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/01/2010, 06:36
erlolialo
 
Fecha de Ingreso: mayo-2009
Mensajes: 72
Antigüedad: 14 años, 11 meses
Puntos: 0
Elegir varios ficheros con JFileChooser

Hola tengo un problema cuando quiero que se puedan elegir varios ficheros con un JFileChooser, no sólo no me deja elegir varios ficheros, sino que si elijo 1 sólo, tampoco me lo coge:

Código:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
   JFileChooser fc = new JFileChooser();
   int returnVal = fc.showOpenDialog(this);
   if (returnVal == JFileChooser.APPROVE_OPTION) {
             
      fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
      if (!fc.isMultiSelectionEnabled()) {
         fc.setMultiSelectionEnabled(true);
      }            
    
      File[] files = fc.getSelectedFiles();
      for (int i=0; i<files.length; i++) {
         jTextArea1.append(files[i].getName() + "\n");
      }
  }                      
}
En cambio usando fc.getSelectedFile() (osea cogiendolos de uno en uno) no me da ningún problema.

Muchas gracias!!!