Non so se ho interpretato bene le tue parole... Ho provato a fare così:
La scritta "prova" esce al momento giusto, mentre il valore nella text viene cambiato alla fine dell'esecuzione del metodo...codice:public class MyThread extends Thread{ String msg; JTextField tf; public void MyThread(){ start(); } public MyThread(String s,JTextField t){ msg=s; tf=t; start(); } public void run(){ System.out.println("prova"); tf.setText(msg); } } metodo upload della classe FileUpload: public void upload( String ftpServer, String user, String password,String fileName, File source,JTextField tLoading ) throws MalformedURLException,IOException,InterruptedException{ if (ftpServer != null && fileName != null && source != null){ System.out.println("Connessione al server"); MyThread t=new MyThread("Connessione al server", tLoading); t.join(); StringBuffer sb = new StringBuffer( "ftp://" ); // check for authentication else assume its anonymous access. if (user != null && password != null){ sb.append( user ); sb.append( ':' ); sb.append( password ); sb.append( '@' ); } sb.append( ftpServer ); sb.append( '/' ); sb.append( fileName ); /* * type ==> a=ASCII mode, i=image (binary) mode, d= file directory * listing */ sb.append( ";type=i" ); BufferedInputStream bis = null; BufferedOutputStream bos = null; try{ // new MyThread("Trasferimento file "+source.getName(), tLoading); System.out.println("Trasferimento file "+source.getName()); URL url = new URL( sb.toString() ); URLConnection urlc = url.openConnection(); bos = new BufferedOutputStream( urlc.getOutputStream() ); bis = new BufferedInputStream( new FileInputStream( source ) ); int i; // read byte by byte until end of stream while ((i = bis.read()) != -1){ bos.write( i ); } } finally{ // new MyThread("Chiusura connessione al server", tLoading); System.out.println("Chiusura connessione al server"); if (bis != null) try{ bis.close(); } catch (IOException ioe){ ioe.printStackTrace(); } if (bos != null) try{ bos.close(); } catch (IOException ioe){ ioe.printStackTrace(); } } } else{ System.out.println( "Input not available." ); } }

Rispondi quotando