Subir archivos con applets

(1/1)

danielo-:
Hola a todos!
Estoy tratando de subir archivos desde un JApplet, pero no me sale, se supone que deberia ser sencillo, pero llevo dias intentandolo, sin exito, y quisiera saber si alguno de ustedes me puden dar la solución, aqui les dejo mi codigo para que chequen

Código
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
/*
 * app.java
 *
 * Created on 19/06/2011, 12:54:05 AM
 */
 
package test;
 
import java.io.File;
import javax.swing.JFileChooser;
 
/**
 *
 * @author pirataX
 */
public class app extends javax.swing.JApplet {
 
   /** Initializes the applet app */
   public void init() {
       try {
           java.awt.EventQueue.invokeAndWait(new Runnable() {
               public void run() {
                   initComponents();
choose();
               }
});
       } catch (Exception ex) {
           ex.printStackTrace();
       }
   }
 
   /** This method is called from within the init() method to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
   @SuppressWarnings("unchecked")
   // <editor-fold defaultstate="collapsed" desc="Generated Code">
   private void initComponents() {
 
       jFileChooser1 = new javax.swing.JFileChooser();
 
       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
       getContentPane().setLayout(layout);
       layout.setHorizontalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addContainerGap())
       );
       layout.setVerticalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
               .addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addContainerGap(22, Short.MAX_VALUE))
       );
   }// </editor-fold>
   public void choose(){
       String archivo="";
       JFileChooser fileChooser = new JFileChooser();
       fileChooser.setMultiSelectionEnabled(true);
int retVal = fileChooser.showOpenDialog(this);
if (retVal == fileChooser.APPROVE_OPTION){
           File[] files = fileChooser.getSelectedFiles();
           for (int i=0; i<files.length; i++) {
               System.out.println(files[i].getName());
           }
}
   }
   // Variables declaration - do not modify
   private javax.swing.JFileChooser jFileChooser1;
   // End of variables declaration
 
}
 
Espero sus ayudas!
 

Navegación

[0] Índice de Mensajes