File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes file upload in swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "file upload in swing" Watch "file upload in swing" New topic

file upload in swing

vidya archana
Ranch Hand

Joined: Oct 29, 2002
Posts: 36
I want to an upload programming in one button of my swing interface.Can any one tell me where I can find examples of upload in swing .
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
I don't know of any examples on the net, but I can tell you what you need:
1. a JFileChooser, so the user can specify what file to upload (if that is not clear, yet).
2. you should read about multithreading - now that you know which file where to put, you should open a background thread so that the ui does not freeze. (in fact you will need two threads: a workerthread and a controlling thread (which can open a progress monitor (see JProgressBar etc.), for example). There is a class SwingWorker provided by sun (not in the JDK! - Swing Tutorial), it might help you. I don't use it, I found my own way through the threading stuff.
3. if you are not familiar with io in java, you should read about that, as well. (the java tutorial is a good start.)
4. I suppose "upload" means to transfer the file over the network to the server - thus you will need compression ( and networking ( (same here: Java Tutorial)
hope this was of any help
[ November 29, 2002: Message edited by: Chantal Ackermann ]
I agree. Here's the link:
subject: file upload in swing
It's not a secret anymore!