FTP Client and SWT

You may remember me talking about the FTP Client that I was writing in Java a couple of weeks ago. Well, I’ve done a bit more work on it… I have to say, as a way of learning SWT it seems to be a good little project! There are a couple of things about SWT which surprised me, not having done any GUI programming since my University days…

The main thing is, the thread model: in SWT, the GUI is all controlled through one thread. If you want to perform an action that is going to take some time (for example, uploading a large file…) then you need to start up a new thread to handle it (so that the GUI didn’t freeze). This isn’t anything unusual, you’d do the same thing in Swing. What is unusual is the fact that you can’t update the GUI from the thread that you started, it all has to be done from the GUI thread. This caused me a fair bit of frustration to start off with! I think it’s OK now, but just something to watch out for.

Anyway, I’ll probably post the source code up here at some point, when it’s a bit more complete (at the moment the ‘features’ include being able to browse a directory structure and upload a file — not download! Not yet ;-). It might help out a few other people, I don’t know. At least as an example of how NOT to code an application!

That’s all for now…


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Related posts

Get new posts by email