Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Show FTP log in JTextField

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! I hope I'm in the right section of the forum, excuse me if I'm not.
In my java program I have to send a file to a ftp server. During the transfer I would like to show in a JTextField(called tLoading) the FTP log( for example: connecting to the server, transfer file, closing connection). I have a class with a JPanel and the JTextField inside the panel. From this class I call the static method upload of another class called FileUpload. This is the method:

The problem is that the JTextField tLoading donesn't change its value. I thought it was a thread problem, so I've created the following class:

and in the upload method I've replaced the tLoading.setText(...) instrucions with

The result is that the message msg is written in the right moment on the stdout but the JTextField value changes only at the end of the upload method. Any suggestions??
 
Ranch Hand
Posts: 443
3
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JTextField changes should be made on the EDT (Event dispatch thread), upload takes time so should not , assuming your load is not on the EDT your upload should spin off a job onto the EDT to update the text field.

http://en.wikipedia.org/wiki/Event_dispatching_thread
 
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch, Ale Io
 
Being a smart alec beats the alternative. This tiny ad knows what I'm talking about:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic